Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens if you nest extern "C"?

Tags:

c++

extern

nested

It looks like nesting extern "C" is legal. For example:

extern "C" extern "C" void foo();

The second extern "C" is essentially ignored. Is that guaranteed by the C++ standard? Where?

like image 426
calvin Avatar asked Jan 04 '18 16:01

calvin


1 Answers

Yes, but it's actually the first extern "C" that's ignored. To quote the standard [dcl.link]:

Linkage specifications nest. When linkage specifications nest, the innermost one determines the language linkage.

like image 170
calvin Avatar answered Nov 07 '22 22:11

calvin