Machine specific predefined names

Larry Jones scjones at sdrc.UUCP
Fri Feb 19 10:22:27 AEST 1988


In article <1988Feb17.115402.12739 at light.uucp>, bvs at light.uucp (Bakul Shah) writes:
< Now our local stdc expert says that an ANSII compatible compiler
< can not use these names [without leading underscores] as they
< belong to the name space reserved
< for the user.  Such a compiler may only predefine names that
< belong to the name space reserved for the implementer, that is,
< names matching the ``_[A-Z_][0-9A-Za-z_]*'' pattern.  He suggests
< that ANSII C compilers for the AMD29000 processor predefine _Am29k
< (for this family) and _Am29000 (for this specific processor).
< 
< So my questions are
< 1) Is our local expert right?

Yes.

< 2) If so, will companies such as SUN, AT&T, DEC etc. predefine
<    names such as _Sparc, _U3b2, _Vax in their ANSII C compilers?
<    Note that doing so will also force change in some `existing
<    practices'.

Hard to say for sure -- most of these companies have stated that they will
provide conforming compilers, but they may just have a switch that gets
rid of all the predefined identifiers rather than change them.  (Nothing
says a compiler must be conforming by default!)

< I also wonder about exactly where the user / implementer boundary
< falls.  If the compiler vendor provides a system call library, is
< it considered part of an implementation?  If so, will the system
< calls have to be _Renamed?  This doesn't make sense to me.
< Clearly, I am missing something here.

That depends on what you mean by "system call library".  An implementor is
free to provide additional library functions with any names at all.  HOWEVER,
none of the standard library routines can use them unless they start with
an underscore.  Thus, it's OK to have a routine in the library called (for
example) "read", but the standard library routine "fread" can't call it.
This doesn't necessarily mean that the system calls have to be renamed as
you can do some amazing magic with clever name mapping in the compiler,
interface libraries, etc.

< PPS: It would be neat if atleast the ANSII compilers were to
<      follow a more regular predefine scheme, something like:
< 
< #define OS_TYPE                 unix
< #define UNIX_TYPE               bsd4_3
< #define MACHINE_TYPE            am29k
< #define AM29K_TYPE              am29000
< #define AM29000_VERSION         B
< 
< These are define hierarchies, starting with OS_TYPE and
< MACHINE_TYPE, so that you can do things like
< 
< #if     OS_TYPE==<os>
< # if    <OS>_TYPE==<os><version>

Unfortunately, as soon as you have meta-symbols in the name (e.g. <OS>),
the poor user is out of luck again and can't use ANY name ending in
_TYPE or _VERSION since it MIGHT be defined as a macro!
-- 

----
Larry Jones                         UUCP: uunet!sdrc!scjones
SDRC                                MAIL: 2000 Eastman Dr., Milford, OH  45150
                                    AT&T: (513) 576-2070
"When all else fails, read the directions."



More information about the Comp.lang.c mailing list