|
From: James W. W. <ja...@wr...> - 2004-12-17 19:55:09
|
Jose' Cruanyes <cru...@ce...> wrote: >I'm trying to compile Quesa with VC++ 6.0, and an issue has risen > >the cast on l-values are not allowed in MS VC++ > >this expression is illegal in C++ (according to MS) > >myStruct * myStructPtr; > >((char*) myStructPtr)) += sizeOfMyStruct > >error C2106 left operand must be l-value... > >there are 44 of them in quesa > >several other changes had been made, but this is serious >do you know a way to avoid it? It looks as though MS may be right. The 1998 C++ standard says: "The result of the expression (T) cast-expression is of type T. The result is an lvalue if T is a reference type, otherwise the result is an rvalue." However, I don't see any way to get CodeWarrior to even give me a warning about this. Would it make sense to say this? ((char*&) myStructPtr)) += sizeOfMyStruct; That compiles in CodeWarrior, and the reference may make it legal, but it looks tricky. -- James W. Walker, ScriptPerfection Enterprises, Inc. <http://www.write-brain.com/> |