From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,4173421f0a339ab7,start X-Google-Attributes: gid1164f8,public From: Nikola Milutinovic Subject: Re: C++ macro error on DEC Unix Date: 1997/08/09 Message-ID: <33EC8AC4.10DD@EUnet.yu>#1/1 X-Deja-AN: 263082009 References: <5sb8r0$4mv$1@coranto.ucs.mun.ca> Organization: JP "Elektrovojvodina" Newsgroups: comp.sys.dec Chuan Wang wrote: > > Hi, > > I have the following macro in the c++ code and compiled on a DEC > Unix machine, it complained about the invalid declaration. > > #define DEFINE_INT_METHODS_BASIC(className) \ > className& className::operator=(INT16 val) \ > {value = val; return *this;} > > the compiler complained at the return value className&. It looks the DEC > Unix doesn't take the reference return value. The macro has been > successfully compiled on Solaris, AIX and HP-UX. Anybody can gave me a > hint why this happened? Thanks. Hi. Macros are considered unwanted resedue of assembler in C and C++. Templates are supposed to eliminate the need for macros in C++, I.m not sure if they succeeded in it, though. Anyway, macros are pre-processed, so if compiler complains, try eliminating the macro as a potential error. Try the whole thing without macro. If it does not work, then it's the problem with C++ syntax. On the other hand, if it works, then there's something wrong with the macro itself. Try just pro-compiling the macros only, with cpp command. Hope this helps. Nix.