webb@webb.UUCP (09/23/87)
We are running C++ 1.2.1. I am trying to compile OOPSLIB (a library of Smalltalk objects for C++, distributed by Keith E. Gorlen of The National Institutes of Health). I first have problems with the compiler complaining that it cannot tell an int from an unsigned int with the following code: overload MAX; inline int MAX(int a,int b) { return a >= b ? a : b; } inline long MAX(long a,long b) { return a >= b ? a : b; } inline float MAX(float a,float b) { return a >= b ? a : b; } inline double MAX(double a,double b) { return a >= b ? a : b; } inline unsigned int MAX(unsigned int a, unsigned int b) { return a >= b ? a : b; } When I comment out the last line that problem goes away, the compilation proceeds further, and I get the following error: "Arraychar.c", line 78: error: name _reader of type type name cannot be overloaded "Arraychar.c", line 78: error: bad base type: void Arraychar The offending line (#78) is: DEFINE_CLASS(Arraychar,Collection,1,NULL,NULL); and DEFINE_CLASS is #define'd as: #define DEFINE_CLASS(classname,basename,version,initor1,initor2)\ overload classname\ _reader;\ static void classname\ _reader(istream& strm, Object& where) { new classname(strm,*(classname*)&where)\; }\ static void classname\ _reader(fileDescTy& fd, Object& where) { new classname(fd,*(classname*)&where);\ }\ Class class_\ classname = Class( class_\ basename, "\ classname\ ", version, sizeof(classname),classname\ _reader, classname\ _reader, initor1, initor2);\ const Class* classname::isA() { return &class_\ classname; } I am not a C++ wizard, (I only dabble) but I need to get this package running. Anyone out there have any ideas? Anyone been able to get this package to run? Thanks for any help you can provide. Peter Webb. {allegra|decvax|harvard|yale|mirror}!ima!applicon!webb, {raybed2|spar|ulowell|sun}!applicon!webb, webb@applicon.com
keith@nih-csl.UUCP (keith gorlen) (09/29/87)
In article <31900003@webb>, webb@webb.applicon.UUCP writes: > > We are running C++ 1.2.1. I am trying to compile OOPSLIB (a library of > Smalltalk objects for C++, distributed by Keith E. Gorlen of The National > Institutes of Health). I first have problems with the compiler complaining > that it cannot tell an int from an unsigned int with the following code: > > overload MAX; > ... > inline unsigned int MAX(unsigned int a, unsigned int b) { return a >= b ? a : b; } Can't duplicate this one. The error message sounds suspiciously like it is coming from a pre-1.2 version of C++. You don't mention what machine your using. A work-around is to delete all the overloaded inlines for ABS, MAX, MIN, etc. and substitute #defines like: #define MAX(a,b) ( (a) >= (b) ? (a) : (b) ) > When I comment out the last line that problem goes away, the compilation > proceeds further, and I get the following error: > > "Arraychar.c", line 78: error: name _reader of type type name cannot be overloaded > "Arraychar.c", line 78: error: bad base type: void Arraychar The file Object.h says the following: The DEFINE_CLASS preprocessor macro composes names by concatenating the "classname" argument with other character strings. This is done by separating the two with \-newline. If this doesn't work on your C preprocessor, try using an empty comment as a separator. If you use this technique, you may have to modify the CC script so that it doesn't use the -C option with the C preprocessor. I think this is what is going wrong in your case. The file DEFCLASS.h contains a version of the DEFINE_CLASS macro that uses empty comments. Edit Object.h to substitute this version of DEFINE_CLASS. [Note -- I think this problem gets fixed in ANSI C.]-- Keith Gorlen phone: (301) 496-5363 Building 12A, Room 2017 uucp: uunet!mimsy!elsie!nih-csl!keith National Institutes of Health Bethesda, MD 20892