List:Internals« Previous MessageNext Message »
From:Vasil Dimov Date:May 30 2007 9:02am
Subject:Re: MySQL-5.1 does not compile with gcc 4.2.0
View as plain text  
On Wed, May 30, 2007 at 10:27:55 +0300, Vasil Dimov wrote:
[...]
> gmake  all-am
> gmake[3]: Entering directory `/mnt/mnt0001/mysql-5.1/client'
> if g++ -DUNDEF_THREADS_HACK -DDEFAULT_MYSQL_HOME="\"/usr/local\""
> -DDATADIR="\"/usr/local/var\"" -I. -I. -I.. -I../include -I../include -I../regex     -O3  
>  -fno-implicit-templates -fno-exceptions -fno-rtti -DMYSQLD_NET_RETRY_COUNT=1000000 -MT
> mysql.o -MD -MP -MF ".deps/mysql.Tpo" -c -o mysql.o mysql.cc; \
>         then mv -f ".deps/mysql.Tpo" ".deps/mysql.Po"; else rm -f ".deps/mysql.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
[...]
> 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)).
[...]

Here is a patch and how I created it.

$ for f in `find ./ -name "*.c" -o -name "*.h" -o -name "*.cc" |xargs grep -El
'[[:space:]=[+)(*/,-]min\(' ` ; do sed -E -i .orig
's#([[:space:]=[+)(*/,-])min\(#\1MIN(#g' $f ; done
$ for f in `find ./ -name "*.c" -o -name "*.h" -o -name "*.cc" |xargs grep -El
'[[:space:]=[+)(*/,-]max\(' ` ; do sed -E -i .orig
's#([[:space:]=[+)(*/,-])max\(#\1MAX(#g' $f ; done

$ vim include/my_global.h (manually fix ``#if !defined(max)'')
$ vim sql/sql_string.cc (manually fix ``MIN(min('')
$ vim sql/mysqld.cc (manually fix ``MIN(min('')
$ cp sql/sql_yacc.yy sql/sql_yacc.yy.orig
$ vim sql/sql_yacc.yy (manually fix ``max'')

$ for f in `find ./ -name "*.orig"` ; do diff -u $f ${f%.orig} ; done >
mysql51_minmax.diff

Now mysql compiles...

-- 
Vasil Dimov
moc.elcaro@stripped        Software Developer @ Oracle/Innobase Oy
gro.DSBeerF@dv                Committer @ FreeBSD.org
gro.d5v@dv                    Home @ Sofia, Bulgaria

Attachment: [text/x-diff] mysql51_minmax.diff
Attachment: [text/x-diff] mysql51_minmax.diff
Attachment: [application/pgp-signature]
Thread
MySQL-5.1 does not compile with gcc 4.2.0Vasil Dimov30 May
  • Re: MySQL-5.1 does not compile with gcc 4.2.0Vasil Dimov30 May
  • Re: MySQL-5.1 does not compile with gcc 4.2.0Vasil Dimov11 Jun