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. Advertisements

  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. Advertisements

  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. Advertisements

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,917
    =?Utf-8?B?UHJvZGlwIEsgU2FoYQ==?=
    Oct 28, 2005
  2. Replies:
    11
    Views:
    1,427
  3. Javier
    Replies:
    2
    Views:
    916
    James Kanze
    Sep 4, 2007
  4. 0m
    Replies:
    26
    Views:
    1,512
    Tim Rentsch
    Nov 10, 2008
  5. fungus
    Replies:
    13
    Views:
    1,244
    fungus
    Oct 31, 2008
  6. Replies:
    2
    Views:
    710
    Andrew Koenig
    Feb 9, 2009
  7. Mara Guida

    const and array of array (of array ...)

    Mara Guida, Sep 2, 2009, in forum: C Programming
    Replies:
    3
    Views:
    847
    David RF
    Sep 3, 2009
  8. Michael Hill

    multi-dem array

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