(j3.2006) binding labels and global identifiers

Malcolm Cohen malcolm
Thu Jun 23 01:21:27 EDT 2011

>So then you try
>    subroutine localname() bind(c, name="_subr_")
>    end subroutine localname
>end interface

Bad move, beginning C names with underscores is highly risky - they are all 
reserved(!) - though 90% of the time one gets away with it, at least until 
porting to another compiler.

I don't know why we'd be so exercised over a user deliberately trying to fake 
out the compiler - "subr_" and all those variants are not reasonable-looking 
names for a C interface!  The user himself is deliberately trying to be 
non-portable, so what.  If his foot disappears, that's his problem.

Anyway, there seem to be many obvious naming conventions that get around any 
plausible occurrence of this problem, and furthermore said naming conventions 
also deal with the FAR more common problem of having internal routine name 
clashes between separate libraries.  No user is going to be pulling out his hair 
saying "I can't find a good name" - the problem as expressed is if the user 
deliberately goes for a bad name then there is a possibility of bad things 
happening.  Well big deal.

Much more likely,
    SUBROUTINE localname() BIND(C,NAME='SUBR')
which works perfectly on Unix including IBM and fails on Windows/Intel, or
    SUBROUTINE localname() BIND(C,NAME='subr')
which works perfectly on Windows/Intel and most Unix, but fails on IBM.

The author isn't going to cross-check his naming scheme with the standard, he's 
going to believe whatever his linker tells him - and if it tells him he is good 
to go then he goes!

................................Malcolm Cohen, Nihon NAG, Tokyo. 

More information about the J3 mailing list