3 ms·
> There isn't a technical reason why foo::x couldn't be the symbol name, literally. how do you do when you want to access your C function from a language which
by jcelerier 4y ago
> There isn't a technical reason why foo::x couldn't be the symbol name, literally.
how do you do when you want to access your C function from a language which is binary-compatible with C but uses :: for something else? [a-zA-Z_][a-zA-Z0-9_]* identifiers are the only thing that the whole world more-or-less standardized around.
e.g. in fortran you can directly import a C function and call it. But "::" in the middle of a function name would very likely fail (I don't know enough fortran to tell for sure but given how the syntax looks...):
subroutine foo (a, n) bind(c)
import
real(kind=c_double), dimension(*) :: a
integer (kind=c_int), value :: n
end subroutine foo
allows to call a "void foo(double *a, int n);" function defined in C. I imagine that
subroutine ns::foo (a, n) bind(c)
would likely not work
- zozbot234 4y ago> how do you do when you want to access your C function from a language which is binary-compatible with C but uses :: for something else? Typically you'd do this by picking a different internal name for the function, and putting the external symbol in quotes.
- jstimpfle 4y agoFair point. The C naming convention with flat names is quite conservative and consequently allows the names to be used directly from most other languages without any language-aware mapping / compatibility layer.