Where should g++ find a 'max' macro or function ?

Michael Svetlik m.svetlik@ssi-schaefer-peem.com
Mon Nov 10 12:17:00 GMT 2003


Hi, folks.

I'm sure, somewhere in a mailing list archive around the globe is the answer - 
I'm too blockheaded to find it.

The problem: a little file
/* -------------------------------------------------------- */
int maxxx (int a, int b) {
	return max(a,b);
}
/* -------------------------------------------------------- */
is pushed into g++ for compilation :
>> g++ -o max.o -c max.c
and produces :
max.c: In function `int maxxx(int, int)':
max.c:4: `max' undeclared (first use this function)
max.c:4: (Each undeclared identifier (bla blaaa ....)

g++ is
>>Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/specs
Configured with: /home/michl/sources/gnu/gcc-3.2.3/configure 
--enable-languages=c,c++
Thread model: posix
gcc version 3.2.3

The output of
>> g++ -E max.c
is 
<output>
# 1 "max.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "max.c"

int maxxx (int a, int b) {

        return max(a,b);



}
</output>

Strange, g++-2.95.3 is capable of translating it correctly, but doesn't 
produce the 'built-in' stuff with '-E'.

I've checked Stroustrup, as well as the archive here, without success. Anyone 
there, who has an idea ?

TIA
Michael



More information about the Gcc-help mailing list