What's the meaning of this variable definition?

Discussion in 'C Programming' started by Klein, Jun 1, 2005.

  1. Klein

    Klein Guest

    const S_Table_Structure * const * cur = table;
     
    Klein, Jun 1, 2005
    #1
    1. Advertising

  2. Klein wrote:
    > const S_Table_Structure * const * cur = table;
    >

    cur is a pointer to
    a const pointer to
    a const S_Table_Structure
    initialized to table
     
    Martin Ambuhl, Jun 1, 2005
    #2
    1. Advertising

  3. Klein

    Philip Paeps Guest

    Klein <> wrote:
    > const S_Table_Structure * const * cur = table;


    You might be interested in the 'cdecl' tool (google for source), which can
    help you easily detangle the most complex declarations...

    - Philip

    --
    Philip Paeps Please don't email any replies
    I follow the newsgroup.

    It's always darkest just before the lights go out.
     
    Philip Paeps, Jun 1, 2005
    #3
  4. Klein

    CBFalconer Guest

    Klein wrote:
    >
    > const S_Table_Structure * const * cur = table;


    Ask your question in the article - the subject is not always
    available to the reader.

    According to cdecl, after replacing the result of a typedef in the
    original statement, the result is:

    cdecl> explain const struct y * const * x
    declare x as pointer to const pointer to const struct y

    Your statement also initializes x with the value table. The only
    thing that is writable in the thing is the pointer x (or cur in
    your case) itself.

    This is the only real reason I have seen to avoid the use of
    typedef in structs. It seems that cdecl cannot handle two
    undefined entities in the same query.

    --
    "If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers." - Keith Thompson
     
    CBFalconer, Jun 1, 2005
    #4
    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. Jianli Shen
    Replies:
    1
    Views:
    621
    Victor Bazarov
    Mar 13, 2005
  2. Ark
    Replies:
    1
    Views:
    445
    Chris Torek
    Aug 7, 2004
  3. Pierre Yves
    Replies:
    2
    Views:
    513
    Pierre Yves
    Jan 10, 2008
  4. Replies:
    4
    Views:
    802
  5. fl
    Replies:
    2
    Views:
    274
    Malcolm McLean
    Dec 2, 2011
Loading...

Share This Page