+ 1
Extern vs extern "C"
Hi 1. I had thought that extern is used to modify the variable in different translation unit... For example, //this is in main.cpp namespace Abc { extern int x; }; //also in main.cpp int Abc::x = 0; above means x is declared in namespace but main.cpp has also its scope (outside of namespace as well) and initialized to 0 Is above correct ? Next query is as below : 2. What if i have extern "C" int x; in question 1? Is extern "C" not only used for namemangling and tell that this can be accessed in c code as well ? With extern "C" also, do we get same effect of extern alone ?
1 Réponse
+ 3
Ketan Lalcheta
A simple search reveals:
https://stackoverflow.com/a/38208679/17982392