external names that aren't valid C identifiers
Norman Diamond
ndiamond at watdaisy.UUCP
Sat Feb 16 08:03:33 AEST 1985
Here is a suggestion that is only moderately ugly, but unambiguous and
won't break any programs.
(1) To refer to an external name (data or function) whose name isn't
a valid C identifier:
extern "external$name" [maybe a type] c_identifier [maybe ()]
(The external name is in a quoted string. The brackets are meta-syntax
to indicate optional tokens.)
For that matter, the external name could also be a valid c identifier,
but old or ported code still wants to use the old name. Anyway, the
external name would not be available to the source code; it would have
to use the C identifier. However, the compiler would generate object
code using the external name.
(2) To define some data or a function with an external name that isn't
a valid C identifer:
"external$name" [maybe a type] c_identifer [maybe () or initializer, etc.]
Same criteria as for the first suggestion. This one's a little harder on
a parser, because the string might look like the beginning of an expression
instead of a declaration. However, it really isn't ambiguous, and it is
surrounded by semicolons (unless it's the first declaration).
The second suggestion is only of interest to anyone who wants C stuff to
be callable from other languages. Admitted, fewer C programmers would
accept this kind of requirement, than for their own need to issue system
calls and such stuff in non-unix environments :-) .
--
Norman Diamond
UUCP: {decvax|utzoo|ihnp4|allegra|clyde}!watmath!watdaisy!ndiamond
CSNET: ndiamond%watdaisy at waterloo.csnet
ARPA: ndiamond%watdaisy%waterloo.csnet at csnet-relay.arpa
"Opinions are those of the keyboard, and do not reflect on me or higher-ups."
More information about the Comp.lang.c
mailing list