Iñaki Ucar writes:

Thoughts?

[1] https://gist.github.com/kevinushey/cfa848be2d39ddd110f893d9b6c5ac9c

I managed to find the part of the C++ standard that specified the semantics of extern "C" linkage, it is [dcl.link]. The term used is "language linkage".

There is no such thing as an inline function in C. That code compiles C++ code with C language linkage.

Reading the C++ standard,, all that the standard seems to specify is language linkage of declarations. Quoting:

# Every implementation shall provide for linkage to functions written in the C
# programming language, "C", and linkage to C ++ functions, "C++".
#
# [ Example:
# complex sqrt(complex);
#  // C++ linkage by default
# extern "C" {
# double sqrt(double);
#  // C linkage
# }
# — end example ]

The standard does not seem to specify the definitions of functions inside a language linkage specification. Either that is unspecified and therefore is a compiler extension; or it is clear that the only thing that belongs inside extern "C" is C code, and there's no such thing as inline functions in C, so declaring C++ code with C linkage would also be considered a compiler extension.

This code compiles in gcc 9, but not in gcc 10. That's life, for compiler extensions.

Attachment: pgpzys8IBYkpI.pgp
Description: PGP signature

_______________________________________________
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org

Reply via email to