From: Nikola Milutinovic <milutinn@EUnet.yu>
Subject: Re: C++ macro error on DEC Unix
Date: 1997/08/09 [thread overview]
Message-ID: <33EC8AC4.10DD@EUnet.yu> (raw)
In-Reply-To: 5sb8r0$4mv$1@coranto.ucs.mun.ca
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.
parent reply other threads:[~1997-08-09 4:00 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <5sb8r0$4mv$1@coranto.ucs.mun.ca>]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox