const and multi dem array compile problem

Discussion in 'C Programming' started by Kevin Houston, Aug 21, 2003.

  1. 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*/
    }
     
    Kevin Houston, Aug 21, 2003
    #1
    1. Advertising

  2. 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 <-berlin.de> wrote in message news:<-berlin.de>...
    > Kevin Houston wrote:
    > > 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
     
    Kevin Houston, Aug 22, 2003
    #2
    1. Advertising

  3. Kevin Houston

    Jirka Klaue Guest

    Kevin Houston wrote:
    >Jirka Klaue <-berlin.de> wrote:
    >>Kevin Houston wrote:
    >>
    >>>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
     
    Jirka Klaue, Aug 22, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UHJvZGlwIEsgU2FoYQ==?=

    Dynamic Loading of User Control with ViewState Preserved (Live Dem

    =?Utf-8?B?UHJvZGlwIEsgU2FoYQ==?=, Oct 28, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    5,687
    =?Utf-8?B?UHJvZGlwIEsgU2FoYQ==?=
    Oct 28, 2005
  2. Javier
    Replies:
    2
    Views:
    573
    James Kanze
    Sep 4, 2007
  3. Ron Ford

    9 11 on 9 11 [dem]

    Ron Ford, Sep 12, 2008, in forum: C Programming
    Replies:
    1
    Views:
    270
    Ron Ford
    Sep 12, 2008
  4. Prodip K Saha
    Replies:
    0
    Views:
    124
    Prodip K Saha
    Oct 28, 2005
  5. Michael Hill

    multi-dem array

    Michael Hill, Aug 29, 2003, in forum: Javascript
    Replies:
    2
    Views:
    105
    Lasse Reichstein Nielsen
    Aug 29, 2003
Loading...

Share This Page