How do I test to see if I am linking in C++ or C using macros?
Say I have code that should link as C in a C++ file, I would use extern "C"{//code here}
which would make my code in a link as C . How would I set up my name.c
file to work for both C and C++. Something like...
#ifdef C++//or other macro
extern "C"{
#endif
#ifdef C++
}
#endif
What is the proper macro to replace the "C++" I have above, and will it be cross platform? or how can I set it up to be cross platform?
Also, What is the significance of having to do the extern "C"{}
for C code in a C++ file?
Any help is appreciated. Thanks in advance.