简体   繁体   中英

What happens if you nest extern “C”?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM