1

There seem to be plenty of answers clarifying the semantics of C99's inline specification, with a single extern translation unit / implementation. If a C++ program / library was to use a C(99) API, with an extern "C" {} wrapper, will it honour the 'single implementation' semantics of the library?

If the C++ compiler is still free to create multiple instantiations as needed, is it required to recognise the C implementation as just another instance, via linker magic, or is this implementation-specific?

From my understanding, the only portable interoperable solution seems to be a static inline specification. Is C99's extern inline fundamentally incompatible with C++? (specifically C++11 and above)

Brett Hale
  • 21,653
  • 2
  • 61
  • 90
  • Edge case but I would consider swapping [tag:c] for [tag:language-lawyer], it attracts the standards-minded folks. – Alex Celeste Aug 03 '17 at 08:51
  • Not an answer, but if the same compiler was used both to compile the C and C++ code, I think it is likely to do the sane thing. While C++11 considers C99 a normative reference, I'm not sure what it means regarding the same keyword interoperability . – StoryTeller - Unslander Monica Aug 03 '17 at 08:51
  • @StoryTeller - I would *expect* the C library to emit a symbol, and C++ code to emit 'weak' symbols, on most platforms using the same compiler, thereby doing the expected thing. But I'm interested in portability of the C library. I'm pretty much resigned to the fact that this is implementation-specific. – Brett Hale Aug 03 '17 at 08:57

0 Answers0