Help Required - compilation error.

Jonathan Wakely jwakely.gcc@gmail.com
Thu Aug 11 14:06:00 GMT 2011


On 11 August 2011 14:50, Jalaiah Murari wrote:
> Hi,
>
> I used GCC 2.7.2.3 in the past to compile the following code:
> class sample
> {
> private:
> unsigned char wk_tmp[20000 - ((int)(long)&(((DATASTRUCTURE*)0)->mydata))];
>
> };
>
>
> Now, When i try to compile using GCC 4.1.2, I get the following error for the above declaration.
> error: array bound is not an integer constant
>
>
> I see that  the array size has to be mentioned directly, instead of dynamic calculation.
> Is there any workaround for this. Do I need to turn on any flag in gcc/g++ when compiling this file.

No, the code is invalid and can't be compiled.

It looks as though you probably want to use offsetof(DATASTRUCTURE, mydata)



More information about the Gcc-help mailing list