Zahid Nisar
Zahid Nisar

Reputation: 882

difference between extern "C" char Table[256][256]; and extern char Table[256][256];

In visual studio code compiled successfully with

extern "C"  char Table[256][256]; 

and if I replace the above code with

extern char Table[256][256];

visual studio starts to give me unresolved external errors for Table?

Upvotes: 3

Views: 174

Answers (1)

Quentin
Quentin

Reputation: 63124

These are two unrelated meanings of the keyword extern.

The first one is the language linkage specifier, which makes the variable interoperable with C.

The second one is the storage class specifier, which declares that the variable is defined elsewhere (which it wasn't, hence the "undefined reference" error).

You could actually use both to declare a variable with C linkage that is defined elsewhere:

extern "C" extern char Table[256][256]; 

Upvotes: 9

Related Questions