Frustrated trying to be portable

Ron Guilmette rfg at NCD.COM
Sun Mar 3 09:33:50 AEST 1991


In article <15333 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
+In article <4108 at lupine.NCD.COM> rfg at NCD.COM (Ron Guilmette) writes:
+>Now that this mistake has been made, is there any "common practice" or
+>defacto standard method by which a program can check to see if it is being
+>compiled by/within a "hosted" implementation or a "standalone" implementation?
+
+It isn't necessary.  If the application requires library functions
+that are required for a hosted implementation but not for a
+freestanding implementation, then it couldn't survive being told
+that it is being compiled by a freestanding implementation anyway.

I think that you have just assumed away a very real problem.

Look.  I have a program which can work, and which can do useful things
even within an environment which only conforms to "standalone" subset
of ANSI C.

However I can also get that program to do more things (or better things,
or different things) if I happen to be compiling it within an environment
which qualifies as a full-blown "hosted" implementation of ANSI C.

Unfortunately, x3j11 didn't provide any standard mechanism for the compiler
(or the preprocessor) to tell the program what sort of "standard" C
environment it is being compiled in, so what I have to do (in lieu of
such a feature) is to give this program to various people and instruct
them each to find out if they have a full-blown "hosted" implementation
or only a paltry "standalone" implementation and then to manually edit
the makefile and either include or dis-include -D__HOSTED_STDC__ in CFLAGS
depending upon the specifics of their implementation.

I wish that I did't have to do all that.

-- 

// Ron Guilmette  -  C++ Entomologist
// Internet: rfg at ncd.com      uucp: ...uunet!lupine!rfg
// New motto:  If it ain't broke, try using a bigger hammer.



More information about the Comp.std.c mailing list