linkage - C++'s extern-"C" functionality to languages other than C -


as known, declaring extern "c" c++ function makes name have c linkage, enabling c code link.

my question - there other programming languages can make c++ function names have linkage to, extern "lisp" or extern "fortran"?

if not, why? internal structure behind "c", makes limitations?

what alternatives?

the c++ standard, 7.5.2 dcl.link, says:

linkage between c++ , non-c++ code fragments can achieved using linkage-specification:

linkage-specification:     extern string-literal { declaration-seqopt}     extern string-literal declaration 

the string-literal indicates required language linkage. international standard specifies semantics string-literals "c" , "c++". use of string-literal other "c" or "c++" conditionally supported, implementation-defined semantics. [ note: therefore, linkage-specification string literal unknown implementation requires diagnostic. —end note ] [ note: recommended spelling of string-literal taken document defining language. example, ada (not ada) , fortran or fortran, depending on vintage. —end note ]

so in principle, implementers can choose support other linkage specifications c , c++.

in practise however, on modern platforms, c linkage lowest common denominator. general rule, these days, binary interop languages other c uses c linkage. on used modern platforms, not see other c , c++ linkage.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -