Re: differences w/ enum in for loop between 3.3.2 and 3.4.3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Steve,

  You are correct about the C++ conflict.

  Look at the 4th bullet in the C/Objective-C/C++ section:

  http://gcc.gnu.org/gcc-3.4/changes.html

corey

On 7/6/05, Steve deRosier <derosier@xxxxxxxxxxxxx> wrote:
> Perhaps this is now against standard ISO C++ now, but in g++ 3.3.2, the following code compiled (snipped and adjusted of course):
> 
> class whatever
> {
>   private:
>     typedef enum { BUFF_LEFT=0, BUFF_RIGHT=1, BUFF_SIZE=2 } eBuffSide;
> }
> 
> void whatever::function( void )
> {
>   for( eBuffSide i = BUFF_LEFT; i <= BUFF_RIGHT; (int(i))++ )
>   {
>     function2( i )
>     ...
>   }
> }
> 
> Now with 3.4.3 I get an error:
> "error: ISO C++ forbids cast to non-reference type used as lvalue"
> 
> What gives?
> 
> Removing the cast gives me an error about not being able to find a postfix operator++.  To make this compile under 3.4.3 I have to code as:
> 
>   for( int i = BUFF_LEFT; i <= BUFF_RIGHT; i++ )
>   {
>     function2( eBuffSide(i) )
>     ...
>   }
> 
> Is there a better way to do this?  (And no, I don't want to make eBuffSide into a class of its own w/ proper operator overloading, it is just intended to be a class-scope named constant.)
> 
> - Steve
>


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux