Top "Extern" questions

extern is an access-specifier in C and C++ which defines a global variable that is visible to all object modules.

Why can't templates be within extern "C" blocks?

This is a follow-up question to an answer to Is it possible to typedef a pointer-to-extern-“C”-function type within …

c++ templates extern linkage
Global variables in C are static or not?

Are global variables in C static or extern by default? If global variables are by default static then it means …

c static global-variables extern
The usage of extern in c++

I've having difficulty understanding how 'extern' works. I've searched Google but there doesn't seem to be the particular example case …

c++ extern
Linker error when calling a C function from C++ code in different VS2010 project

I'm trying to include some C code I found in our C++ project. The function is defined like this in …

c++ c visual-studio-2010 extern lnk2001
Why does initializing an extern variable inside a function give an error?

This code compiles fine: extern int i = 10; void test() { std::cout << "Hi" << i << std::…

c++ declaration definition extern
extern enum in c++

I have an enum I have declared in some .h file: typedef enum { NONE, ONE, TWO, THREE } MYENUM; in a …

c++ syntax compilation extern linkage
"FOUNDATION_EXPORT" vs "extern"

I would like to ask what's the reason behind using FOUNDATION_EXPORT instead of extern in Objective C projects. I've …

objective-c extern
Why does "extern const int n;" not work as expected?

My project consists of only two source files: a.cpp: const int n = 8; b.cpp: extern const int n; int …

c++ constants declaration extern
Why do I get "PInvokeStackImbalance was detected" for this simple example?

I'm creating a very simple PInvoke sample: extern "C" __declspec(dllexport) int Add(int a, int b) { return a + b; } […

.net pinvoke extern
Reasons to use Static functions and variables in C

I wonder about the use of the static keyword as scope limiting for variables in a file, in C. The …

c static linker extern