Hi,
The following code-fragment won't compile in the .Net-studio but it does
compile in Borland. So is anyone familiar with this problem, or someone
knows how to solve it?
void MidpointSolver::Solve(float* next_state, const float* current_state,
float time, float h, const unsigned int dim)
{
float derivative_state[dim];
...
}
The reported error is: C2057 - 'expected constant expression'. So the
compiler doesnt see 'dim' as an constant or something like that?!?
Anyone? 7 1290
"Martijn" <r.m.maatman_@_student.utwente.nl> wrote in message
news:c6**********@netlx020.civ.utwente.nl... Hi,
The following code-fragment won't compile in the .Net-studio but it does compile in Borland. So is anyone familiar with this problem, or someone knows how to solve it?
void MidpointSolver::Solve(float* next_state, const float* current_state, float time, float h, const unsigned int dim) { float derivative_state[dim]; ... }
The reported error is: C2057 - 'expected constant expression'. So the compiler doesnt see 'dim' as an constant or something like that?!?
Anyone?
No .NET is right. In this case constant expression means compile time
constant, which obviously dim isn't even though you've declared it as const.
The best way to do this is to use a vector.
#include <vector>
void MidpointSolver::Solve(float* next_state, const float* current_state,
float time, float h, const unsigned int dim)
{
std::vector<float> derivative_state(dim);
...
Now I can't see the rest of your code, but I wouldn't be surprised if it
compiled unchanged, even though you've switched from an array to a vector.
john
"Martijn" <r.m.maatman_@_student.utwente.nl> wrote in message
news:c6**********@netlx020.civ.utwente.nl... Hi,
The following code-fragment won't compile in the .Net-studio but it does compile in Borland. So is anyone familiar with this problem, or someone knows how to solve it?
void MidpointSolver::Solve(float* next_state, const float* current_state, float time, float h, const unsigned int dim) { float derivative_state[dim]; ... }
The reported error is: C2057 - 'expected constant expression'. So the compiler doesnt see 'dim' as an constant or something like that?!?
It is not a constant expression, since it is not assigned a value at the
place of definition. It is as if you define a variabled-sized built in
array.
If you define dim inside the function scope then you will have no problem.
E.g.:
void MidpointSolver::Solve(float* next_state, const float* current_state,
float time, float h, const unsigned int dim)
{
const unsigned SIZE=7;
float derivative_state[SIZE];
...
}
Ioannis Vranos
"Martijn" <r.m.maatman_@_student.utwente.nl> wrote in message
news:c6**********@netlx020.civ.utwente.nl... Hi,
The following code-fragment won't compile in the .Net-studio but it does compile in Borland. So is anyone familiar with this problem, or someone knows how to solve it?
void MidpointSolver::Solve(float* next_state, const float* current_state, float time, float h, const unsigned int dim) { float derivative_state[dim]; ... }
The reported error is: C2057 - 'expected constant expression'. So the compiler doesnt see 'dim' as an constant or something like that?!?
Anyone?
The reported error is correct because dim is not a constant as the compiler
cannot see its actual value (which should be a defined constant). However,
itīs hard to believe that Borland will compile this without at least a
warning. Try to increase your warning levels and recompile under Borland
(BTW which version?).
HTH
Chris
"Chris Theis" <Ch*************@nospam.cern.ch> wrote in
news:c6**********@sunnews.cern.ch: "Martijn" <r.m.maatman_@_student.utwente.nl> wrote in message news:c6**********@netlx020.civ.utwente.nl... Hi,
The following code-fragment won't compile in the .Net-studio but it does compile in Borland. So is anyone familiar with this problem, or someone knows how to solve it?
void MidpointSolver::Solve(float* next_state, const float* current_state, float time, float h, const unsigned int dim) { float derivative_state[dim]; ... }
The reported error is: C2057 - 'expected constant expression'. So the compiler doesnt see 'dim' as an constant or something like that?!?
Anyone?
The reported error is correct because dim is not a constant as the compiler cannot see its actual value (which should be a defined constant). However, itīs hard to believe that Borland will compile this without at least a warning. Try to increase your warning levels and recompile under Borland (BTW which version?).
It is possible that Borland might have implemented variable length arrays
as a compiler extension? But from a C++ standpoint, dim isn't a compile-
time constant and cannot be used as an array size specifier (from a
Standard point of view....)
"Andre Kostur" <nn******@kostur.net> wrote in message
news:Xn*******************************@207.35.177. 135...
[SNIP]> > The reported error is correct because dim is not a constant as the compiler cannot see its actual value (which should be a defined constant). However, itīs hard to believe that Borland will compile this without at least a warning. Try to increase your warning levels and recompile under Borland (BTW which version?).
It is possible that Borland might have implemented variable length arrays as a compiler extension?
[SNIP]
Iīve also had that idea but I doubt that they do not at least give a hint
via a warning. Unfortunately I do not have a Borland compiler available to
check this. Hence, probably somebody else could shed some more light onto
this matter.
Chris
"Chris Theis" <Ch*************@nospam.cern.ch> wrote in message
news:c6**********@sunnews.cern.ch... "Martijn" <r.m.maatman_@_student.utwente.nl> wrote in message news:c6**********@netlx020.civ.utwente.nl... Hi,
The following code-fragment won't compile in the .Net-studio but it does compile in Borland. So is anyone familiar with this problem, or someone knows how to solve it?
void MidpointSolver::Solve(float* next_state, const float*
current_state, float time, float h, const unsigned int dim) { float derivative_state[dim]; ... }
The reported error is: C2057 - 'expected constant expression'. So the compiler doesnt see 'dim' as an constant or something like that?!?
Anyone?
The reported error is correct because dim is not a constant as the
compiler cannot see its actual value (which should be a defined constant). However, itīs hard to believe that Borland will compile this without at least a warning. Try to increase your warning levels and recompile under Borland (BTW which version?).
Many compilers support VLAs as a system extension, the same happens with
long long. All of course give an error when in strict ISO mode.
Ioannis Vranos
In message <c6**********@sunnews.cern.ch>, Chris Theis
<Ch*************@nospam.cern.ch> writes "Andre Kostur" <nn******@kostur.net> wrote in message news:Xn*******************************@207.35.177 .135... [SNIP]> > The reported error is correct because dim is not a constant as the > compiler cannot see its actual value (which should be a defined > constant). However, itīs hard to believe that Borland will compile > this without at least a warning. Try to increase your warning levels > and recompile under Borland (BTW which version?).
It is possible that Borland might have implemented variable length arrays as a compiler extension?
[SNIP] Iīve also had that idea but I doubt that they do not at least give a hint via a warning. Unfortunately I do not have a Borland compiler available to check this. Hence, probably somebody else could shed some more light onto this matter.
Not BCB5, at least:
void Solve(float* next_state, const float* current_state,
float time, float h, const unsigned int dim)
{
float derivative_state[dim];
}
[C++ Error] Unit1.cpp(6): E2313 Constant expression required
--
Richard Herring This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jeff Epler |
last post by:
Hello.
Recently, Generator Comprehensions were mentioned again on python-list.
I have written an implementation for the compiler module. To try it
out, however, you must be able to rebuild...
|
by: Bryan Parkoff |
last post by:
You may notice that switch (...) is much faster than function that can
gain a big improved performance because it only use JMP instruction however
function is required to use CALL, PUSH, and POP...
|
by: Bjorn |
last post by:
I'm using interfaces in C++ by declaring classes with only pure virtual
methods. If then someone wants to implement the interface they
needs to inherit from the class. If the implementing class...
|
by: Tao Wang |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I saw cuj's conformance roundup, but the result is quite old. I think
many people like me want to know newer c++ standard conformance test...
|
by: joshc |
last post by:
I'm writing some C to be used in an embedded environment and the code
needs to be optimized. I have a question about optimizing compilers in
general. I'm using GCC for the workstation and Diab...
|
by: pj |
last post by:
(Was originally, probably wrongly, posted to the vc subgroup.)
(This doesn't appear to be a c# problem, but a problem with a bug in
the Visual Studio c# compiler, but, any help will be welcome...)...
|
by: rollasoc |
last post by:
Hi,
I seem to be getting a compiler error
Internal Compiler Error (0xc0000005 at address 535DB439): likely culprit is
'BIND'.
An internal error has occurred in the compiler. To work around...
|
by: Mark Rockman |
last post by:
------ Build started: Project: USDAver2, Configuration: Debug .NET ------
Preparing resources...
Updating references...
Performing main compilation...
error CS0583: Internal Compiler Error...
|
by: toton |
last post by:
Hi,
Anyone have a link to comparative study of different C++ compilers
and how much they conform to C++ language standard? Most of the big
platforms I know have GCC which well supports C++...
|
by: Miroslaw Makowiecki |
last post by:
Where can I download Comeau compiler as a trial version?
Thanks in advice.
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |