May I know what does this code means? As I know when there is any C header then we should use extern "C" if we want to compile them into a c++ module.Am i right?
But what is char *getwd(char *); since it is not a header of C. I need explicit explanation and simple example.Thanks.
DOes the above code doin anythg?Since char * doesnt state where the path of current directory save to.The code above actually done ntg or is doing thing as you mentioned in the previous post ? How i know char *getwd(char *); is written in header.h ?
1. char *getwd(char *); is a declaration of a function that takes a char pointer, returns a char pointer, and has name 'getwd'. Where did you find that piece of code?
man getwd wrote:
For portability and security reasons, use of getwd() is deprecated.
2. The extern"C" tells the linker and the C++ compiler that this declared function prototype corresponds to an implementation of the function that has been compiled with C compiler.
3. When you use functions and types written by someone else and available as libraries, you also use the documentation of those libraries to find out what they have and do.
It is telling linker that that fuction is using C-style calls, name mangling etc. So you can link file containing that function which was compiled by C-compiler.
Basically it tells: this function was compiled in C, not C++. It is special, threat it accordingly during code generation.