Issue 1215

Summary: min and max macro's in solar.h over-ride std::min and std::max
Product: porting Reporter: issues@www <issues>
Component: documentationAssignee: jens-heiner.rechtien
Status: CLOSED FIXED QA Contact: issues@www <issues>
Severity: Trivial    
Priority: P2 CC: issues, jayvdb
Version: 632   
Target Milestone: not determined   
Hardware: SGI   
OS: IRIX   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---
Issue Depends on:    
Issue Blocks: 1209    
Attachments:
Description Flags
tools/inc/solar.h : Patch to remove min/max macro's from c++
none
vcl/unx/source/gdi/xfont.cxx : Patch to use std::min
none
vcl/unx/source/gdi/xfont.cxx : Patch to build on IRIX, needs further testing none

Description issues@www 2001-07-13 06:30:51 UTC
I have been building with STLport-0609 which is essentially STLport-4.1b8 
(alpha), and I have been getting build breakages all over the place ... due to 
min and max macro's in solar.h

Making: ../../unxirxm3.pro/obj/stream.obj
g++ -c -w -nostdinc++ -I. -I. -I../inc -I../../inc -I../../unx/inc -
I../../unxirxm3.pro/inc -I. -I/projects/sise/openoffice/devel/workpits/632-irix-
gcc2.95.2-STL_port/workarea/solver/632/unxirxm3.pro/inc -
I/projects/sise/openoffice/devel/workpits/632-irix-gcc2.95.2-
STL_port/workarea/solver/632/unxirxm3.pro/inc/external -
I/projects/sise/openoffice/devel/workpits/632-irix-gcc2.95.2-
STL_port/workarea/solenv/unxirxm3/inc -
I/projects/sise/openoffice/devel/workpits/632-irix-gcc2.95.2-
STL_port/workarea/solenv/inc -I/projects/sise/openoffice/devel/workpits/632-
irix-gcc2.95.2-STL_port/workarea/res -I/usr/local/STLport-0601//stlport -
I/projects/sise/openoffice/devel/workpits/632-irix-gcc2.95.2-
STL_port/workarea/solenv/inc/Xp31 -I/usr/local/java_1.2.2/usr/java//include -
I/usr/local/java_1.2.2/usr/java//include/irix -
I/usr/local/java_1.2.2/usr/java//include/native_threads/include     -I. -
I../../res -I. -I/projects/sise/openoffice/devel/workpits/632-irix-gcc2.95.2-
STL_port/workarea/solenv/unxlngi3/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/include -
I/projects/sise/openoffice/devel/workpits/632-irix-gcc2.95.2-
STL_port/workarea/solenv/unxlngi3/usr/include -O2   -fno-for-scope -
fpermissive -fno-exceptions     -DIRIX -DUNX -DVCL -DGCC -DC295 -DMIPS -
DUSE_PSPRINT -DTF_UCB -DENABLEUNICODE -DTF_FILTER -DCVER=C295 -D_USE_NAMESPACE -
D_PTHREADS -D_REENTRANT -DNEW_SOLAR -D_USE_NAMESPACE=1 -DSTLPORT_VERSION=400 -
D__DMAKE -DUNIX -DSUPD=632 -DBUILD=6483 -DSOLAR_PLUGIN -DVCL -DSO3 -DPRODUCT -
DNDEBUG -DPRODUCT_FULL -DOPTIMIZE -DEXCEPTIONS_OFF -DGUI -DSOLAR_JAVA -
DSRC632  -DTF_ONE51 -DMULTITHREAD  -
o ../../unxirxm3.pro/obj/stream.o /projects/sise/openoffice/devel/workpits/632-
irix-gcc2.95.2-STL_port/workarea/tools/source/stream/stream.cxx
/projects/sise/openoffice/devel/workpits/632-irix-gcc2.95.2-
STL_port/workarea/tools/source/stream/stream.cxx: In method `ErrCode 
SvAsyncLockBytes::ReadAt(long unsigned int, void *, long unsigned int, ULONG *) 
const':
/projects/sise/openoffice/devel/workpits/632-irix-gcc2.95.2-
STL_port/workarea/tools/source/stream/stream.cxx:358: parse error before `('
/projects/sise/openoffice/devel/workpits/632-irix-gcc2.95.2-
STL_port/workarea/tools/source/stream/stream.cxx: In method `ErrCode 
SvAsyncLockBytes::WriteAt(long unsigned int, const void *, long unsigned int, 
ULONG *)':
/projects/sise/openoffice/devel/workpits/632-irix-gcc2.95.2-
STL_port/workarea/tools/source/stream/stream.cxx:375: parse error before `('
dmake:  Error code 1, while making '../../unxirxm3.pro/obj/stream.obj'
---* TG_SLO.MK *---

I would be interested in why I have this error ... I can only assume it is the 
version of STLport I am using.

I am currently attempting to wrap the macro's in #ifndef __cplusplus.  This 
could potentially break any c++ which does not use std::  .
Comment 1 issues@www 2001-07-13 12:29:55 UTC
Created attachment 374 [details]
tools/inc/solar.h : Patch to remove min/max macro's from c++
Comment 2 issues@www 2001-07-13 20:40:05 UTC
Created attachment 381 [details]
vcl/unx/source/gdi/xfont.cxx : Patch to use std::min
Comment 3 issues@www 2001-07-13 20:44:00 UTC
vcl is the first module which breaks on this change to solar.h  
vcl is still broken and attachment 381 [details] should not be pushed in.  Damn why cant 
they be simple one line fixes.
Comment 4 issues@www 2001-07-13 21:57:10 UTC
Created attachment 382 [details]
vcl/unx/source/gdi/xfont.cxx : Patch to build on IRIX, needs further testing
Comment 5 issues@www 2001-07-14 02:33:47 UTC
I am not even going to pretend that 382 is correct, however it does build and 
pass checkdll.  Further changes will be needed on other platforms which I can 
not build.

vcl/mac/source/app/NoSharMain.cxx:                        applZone->moreMast = 
(short) min(numMasterPointersDesired, SHRT_MAX);

vcl/win/source/app/salinfo.cxx:                                           + max
(pSection->SizeOfRawData, pSection->Misc.VirtualSize);

There is also a good chance that there are other uses of the min/max macro's 
within c++ code which have not come within reach of my compiler.
Comment 6 issues@www 2001-07-17 07:16:34 UTC
Sander .. I have just completed a build with this patch ... and there were no 
other affected files (on IRIX).
Comment 7 Martin Hollmichel 2001-07-26 15:11:02 UTC
Heiner, can please take care of these ?
Comment 8 jens-heiner.rechtien 2001-08-23 09:26:40 UTC
Accepted
Comment 9 jens-heiner.rechtien 2001-08-23 16:10:39 UTC
The only way to really fix this problem is to remove the min()/max() 
macros from solar.h and use the std::min()/std::max() templates 
everywhere.
Comment 10 zeroj 2001-09-01 03:40:08 UTC
Wouldnt this result in min()/max() not being available in files which 
are not c++? 
Comment 11 jens-heiner.rechtien 2001-10-12 18:17:35 UTC
fixed in SRC641 g
Comment 12 jens-heiner.rechtien 2001-11-06 20:40:48 UTC
closed