Re: MS VisualStudio C++ specific fixes

From: Guido Serassio <serassio@dont-contact.us>
Date: Mon, 25 Nov 2002 09:46:16 +0100

Hi Henrik,

Il 08.24 25/11/2002 Henrik Nordstrom ha scritto:
>Can you explain the problem, with some code examples?
>
>The error message as such makes sense. ++ and -- is only meaningful on
>l-value expressions.
>
>Regards
>Henrik

This is the not working code:

log_type &operator++ (log_type &aLogType)
{
     aLogType = (log_type)++((int)aLogType);
     return aLogType;
}

Compiling...
client_db.cc
C:\work\nt-3.0\src\client_db.cc(163) : error C2105: '++' needs l-value
Error executing cl.exe.

This works:

log_type &operator++ (log_type &aLogType)
{
     int i = (int)aLogType;
     aLogType = (log_type)(++i);
     return aLogType;
}

Regards

Guido

>Guido Serassio wrote:
> >
> > Hi Robert,
> >
> > After some search on Google about the error C2105 "'++' needs l-value", I
> > have found some contrasting explanations about gcc++ and VisualStudio C++
> > incompatibility.
> > So I made some source changes to fix this MS VisualStudio C++ compile
> > errors, and all builds fine on MinGW too.
> >
> > What is Your opinion about this ?
> >
> > Regards
> >
> > Guido
> >

-
=======================================================
Serassio Guido
Via Albenga, 11/4 10134 - Torino - ITALY
E-mail: guido.serassio@serassio.it
WWW: http://www.serassio.it
Received on Mon Nov 25 2002 - 01:46:20 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:18:49 MST