From: Date: May 30 2007 9:27am Subject: MySQL-5.1 does not compile with gcc 4.2.0 List-Archive: http://lists.mysql.com/internals/34680 Message-Id: <20070530072755.GA73076@polejan.hw.v5d.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tThc/1wpZn/ma/RB" --tThc/1wpZn/ma/RB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, ### get the latest BK source mysql-5.1$ bkf pull INFO-generating patch, please wait... INFO-nothing to send. mysql-5.1$=20 ### configure mysql-5.1$ ./BUILD/autorun.sh mysql-5.1$ ./configure ### try to build mysql-5.1$ gmake =2E.. gmake all-am gmake[3]: Entering directory `/mnt/mnt0001/mysql-5.1/client' if g++ -DUNDEF_THREADS_HACK -DDEFAULT_MYSQL_HOME=3D"\"/usr/local\"" -DDATAD= IR=3D"\"/usr/local/var\"" -I. -I. -I.. -I../include -I../include -I../regex= -O3 -fno-implicit-templates -fno-exceptions -fno-rtti -DMYSQLD_NET_= RETRY_COUNT=3D1000000 -MT mysql.o -MD -MP -MF ".deps/mysql.Tpo" -c -o mysql= =2Eo mysql.cc; \ then mv -f ".deps/mysql.Tpo" ".deps/mysql.Po"; else rm -f ".deps/my= sql.Tpo"; exit 1; fi mysql.cc: In function 'void print_table_data(MYSQL_RES*)': mysql.cc:2361: error: 'max' was not declared in this scope mysql.cc:2363: error: 'max' was not declared in this scope mysql.cc:2384: error: 'min' was not declared in this scope gmake[3]: *** [mysql.o] Error 1 gmake[3]: Leaving directory `/mnt/mnt0001/mysql-5.1/client' gmake[2]: *** [all] Error 2 gmake[2]: Leaving directory `/mnt/mnt0001/mysql-5.1/client' gmake[1]: *** [all-recursive] Error 1 gmake[1]: Leaving directory `/mnt/mnt0001/mysql-5.1' gmake: *** [all] Error 2 mysql-5.1$=20 I applied this patch to isolate the problem: --- include/my_global.h.orig Wed May 30 10:14:55 2007 +++ include/my_global.h Wed May 30 10:16:02 2007 @@ -1488,7 +1488,17 @@ * Include standard definitions of operator new and delete. */ #ifdef __cplusplus +#if defined(max) +#warning max is defined before #include +#else +#warning max is not defined before #include +#endif #include +#if defined(max) +#warning max is defined before #include +#else +#warning max is not defined before #include +#endif #endif #else /* and got =2E.. gmake[3]: Entering directory `/mnt/mnt0001/mysql-5.1/client' if g++ -DUNDEF_THREADS_HACK -DDEFAULT_MYSQL_HOME=3D"\"/usr/local\"" -DDATAD= IR=3D"\"/usr/local/var\"" -I. -I. -I.. -I../include -I../include -I../regex= -O3 -fno-implicit-templates -fno-exceptions -fno-rtti -DMYSQLD_NET_= RETRY_COUNT=3D1000000 -MT mysql.o -MD -MP -MF ".deps/mysql.Tpo" -c -o mysql= =2Eo mysql.cc; \ then mv -f ".deps/mysql.Tpo" ".deps/mysql.Po"; else rm -f ".deps/my= sql.Tpo"; exit 1; fi In file included from client_priv.h:18, from mysql.cc:31: =2E./include/my_global.h:1492:2: warning: #warning max is defined before #i= nclude =2E./include/my_global.h:1500:2: warning: #warning max is not defined befor= e #include mysql.cc: In function 'void print_table_data(MYSQL_RES*)': mysql.cc:2361: error: 'max' was not declared in this scope mysql.cc:2363: error: 'max' was not declared in this scope mysql.cc:2384: error: 'min' was not declared in this scope gmake[3]: *** [mysql.o] Error 1 gmake[3]: Leaving directory `/mnt/mnt0001/mysql-5.1/client' gmake[2]: *** [all] Error 2 gmake[2]: Leaving directory `/mnt/mnt0001/mysql-5.1/client' gmake[1]: *** [all-recursive] Error 1 gmake[1]: Leaving directory `/mnt/mnt0001/mysql-5.1' gmake: *** [all] Error 2 mysql-5.1$=20 ### platform and compiler details $ gcc -v Using built-in specs. Target: amd64-undermydesk-freebsd Configured with: FreeBSD/amd64 system compiler Thread model: posix gcc version 4.2.0 20070514 [FreeBSD] $ $ grep -n -B2 'undef max' /usr/include/c++/4.2/bits/c++config.h=20 202-// For example, is known to #define min and max as macros... 203-#undef min 204:#undef max ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.2.0/gcc-g++-4.2.0.tar.bz2 indeed contains this code in gcc-4.2.0/libstdc++-v3/include/bits/c++config so I guess it is not FreeBSD related, but rather gcc 4.2.0 related (maybe also in earlier versions). One solution would be to s/max/MAX/ everywhere in the code. (this way it will also be clear that it is a macro, not a function, and may have unexpected results if called like MAX(a++, b)). Hope that helps. --=20 Vasil Dimov moc.elcaro@stripped Software Developer @ Oracle/Innobase Oy gro.DSBeerF@dv Committer @ FreeBSD.org gro.d5v@dv Home @ Sofia, Bulgaria --tThc/1wpZn/ma/RB Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- iD8DBQFGXSd7Fw6SP/bBpCARAhlaAJ9S5PdbRle39Fp+Q78pNEvEX2SmeQCgz3Xm MxusU2nkJmfwdZPAaTbHBBI= =tDzK -----END PGP SIGNATURE----- --tThc/1wpZn/ma/RB--