|
From: Luke D. <cod...@ho...> - 2006-08-09 12:35:06
|
----- Original Message -----
From: "Christoph Harder" <sha...@ar...>
To: "MinGW Users List" <min...@li...>
Sent: Wednesday, August 09, 2006 2:32 AM
Subject: Re: [Mingw-users] unknown error
> Hi,
> thank you the compile log is now only five lines :)
>
> I used your tips with the new and std:: and I also found out that I
> didn't need #include<vector> in the main.cpp.
> But still the allocation fails. It says something like function call in
> constant expression. I tried to read the values in temporary variables,
> but it say again that t0,t1 (the temp vars) cannot appear as constant
> expression.
>
> Any workarounds for this?
>
> Regards,
> Christoph
>
> The problem:
> int * Plasma;
>
> Plasma=new(std::nothrow)int[Config.getInt("PlasmaWidth")][Config.getInt("PlasmaHeight")];
You can't use a simple 'new' to create multi-dimensional arrays in general.
It is only allowed when all of the dimensions are constant except the first
one, e.g.:
int (*array2d)[10] = new int[x][10];
In your case though you will probably want another way. See the following
FAQ for ideas:
http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.16
Luke
>
> The current compile log:
> E:\files\programmierung\arbeitsproben\plasmagen\src\main.cpp In
> function `int SDL_main(int, char**)':
> 189 E:\files\programmierung\arbeitsproben\plasmagen\src\main.cpp
> `Config' cannot appear in a constant-expression
> 189 E:\files\programmierung\arbeitsproben\plasmagen\src\main.cpp `.'
> cannot appear in a constant-expression
> 189 E:\files\programmierung\arbeitsproben\plasmagen\src\main.cpp a
> function call cannot appear in a constant-expression
> E:\files\programmierung\arbeitsproben\plasmagen\src\Makefile.win
> [Build Error] [main.o] Error 1
>
> Luke Dunstan wrote:
>> ----- Original Message -----
>> From: "Christoph Harder" <sha...@ar...>
>> To: <min...@li...>
>> Sent: Monday, August 07, 2006 10:37 PM
>> Subject: [Mingw-users] unknown error
>>
>>
>>
>>> Hi,
>>> currently I'm programming a small plasma generator, but since I tried to
>>> use "int *Plasma; Plasma=new(nothrow)int[PlasmaWidth][PlasmaHeight];"
>>> nothing works anymore :(
>>> Even if I delete it the errors occur.
>>> I have tried everything I know, but nothing changes. I don't even know
>>> what this compile log means
>>> (http://home.arcor.de/familie.harder/cpp/doc/compile.log.txt).
>>>
>>> Maybe someone can look at the
>>> sources(http://home.arcor.de/familie.harder/cpp/doc/project.htm) and
>>> tell me whats wrong?
>>>
>>> Thanks in advance,
>>> Christoph
>>>
>>
>> Try std::nothrow, and #include <new>
>>
>> Luke
>>
>>
>> -------------------------------------------------------------------------
>> Using Tomcat but need to do more? Need to support web services, security?
>> Get stuff done quickly with pre-integrated technology to make your job
>> easier
>> Download IBM WebSphere Application Server v.1.0.1 based on Apache
>> Geronimo
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>> _______________________________________________
>> MinGW-users mailing list
>> Min...@li...
>>
>> You may change your MinGW Account Options or unsubscribe at:
>> https://lists.sourceforge.net/lists/listinfo/mingw-users
>>
>>
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> MinGW-users mailing list
> Min...@li...
>
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
>
|