Compilation error

Dave Dodge dododge at dododge.net
Sun Sep 9 04:34:10 UTC 2007


On Sun, Sep 09, 2007 at 09:34:53AM +0530, kannappan at tesbv.com wrote:
> I dont think its bogus statement. This piece of code is working with  
> the native host compiler.

"My compiler takes it" is seldom a reliable way of checking that code
is really C.  Many C compilers have custom extensions to the C
language, and they usually have those extensions enabled _by default_.
You have to go out of your way to get the compiler to stick to
Standard C.  With gcc for example I normally use (at a minimum):

  -std=c99 -pedantic -Wall -Wextra

As was said:

> > This is the old cast-as-lvalue extension.

You're trying to do this:

  ((type)x)++

which is not allowed in Standard C.  The cast produces a value, not a
modifiable object.  The ++ operator requires a modifiable object.  If
your compiler is allowing it, then it must have an extension to create
objects from casts.  As mentioned, older versions of gcc had just such
an extension.

Look in your compiler's manual for options to get strict Standard C
compliance, and then try the code with those options turned on.

                                                  -Dave Dodge



More information about the uClibc mailing list