const and multi dem array compile problem

K

Kevin Houston

Why do I get the following compiler error:

**Illegal type 'const const int'**


when I try to compile this?


int somefunction(int someparameter)
{
const int myarray[][2] = /* Why won't it let me use const? */
{
{5, 37},
{6, 36},
};
/*the rest of the somefunction definition here*/
}
 
K

Kevin Houston

This is being compiled on a C only (not C++) compiler (labwindows
cvi).

The return statement is in my code I just left it out here for
purposes of illustration.

The real question is why can't I use "const" where I did.

What is "C&P"

Jirka Klaue said:
Kevin said:
Why do I get the following compiler error:

**Illegal type 'const const int'**
^^^^^ ^^^^^
...
const int myarray[][2] = /* Why won't it let me use const? */
^^^^^

Failure to use C&P, by chance?

Jirka
 
J

Jirka Klaue

Kevin said:
Jirka Klaue said:
Kevin said:
Why do I get the following compiler error:

**Illegal type 'const const int'**
^^^^^ ^^^^^
...
const int myarray[][2] = /* Why won't it let me use const? */
^^^^^

Failure to use C&P, by chance?
....
The real question is why can't I use "const" where I did.

You can. The question is why the compiler spits out *two* const's in it's
error message although you only wrote one.
What is "C&P"

Copy & Paste. I suspect in the code you really compiled, you wrote:

const const int myarray[][2] ...

Jirka
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top