Re: Identifying compiler
Rune Allnor wrote:
I am programming some C files that will be called from matlab.
According to the matlab documentation, a certain amount of
"voodoo" needs to be included if one uses one particular
compiler, to ensure some details to be handled correctly.
Now, I wonder how I can detect at compile time if this
compiler is used. If so, I might be able to make a header
like
#ifdef SomeCompiler
/* voodoo to be included */
#endif
- Is this a good way of doing things?
Not really. A better solution would be to make two separate
headers, in two different directories, and include one or the
other by means of a -I (or /I) option in the command line. It
it really is just one little tweak, this is a lot of extra work,
but my experience has been that even when it starts out as one
little tweak, it ends up affecting a lot of things, and you're
headers quickly become unreadable unless you use the separate
headers in separate directories solution (in which case, you end
up getting lost in a plethorie of small files -- but at least,
they're readable).
- Where can I find out what to substitute for "SomeCompiler"
above? The above must be valid for any Borland compiler.
You invoke the compiler. I've yet to find two compilers which
could be invoked by the same command line, so you already have a
means of choosing the invocation command line which depends on
the compiler (or more likely, on about a dozen different
factors: compiler, OS, architecture, debug or no, DLL or static
library...). Just define a name for each of your compilers, and
add a -D (or /D, or whatever) in your command line to define it.
(Note that this can be used with token pasting in an include
declaration to change the name of the included file.)
--
James Kanze GABI Software
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]