Difference b/w storage class and storage class specifier - C

This is a discussion on Difference b/w storage class and storage class specifier - C ; Hi, What is the difference b/w a "storage class" and "storage class specifier"? It is said that there, Storage Class --> automatic static ( K&R ) Storage Class Specifier --> auto extern register static typedef What does a specifier mean? ...

+ Reply to Thread
Results 1 to 3 of 3

Difference b/w storage class and storage class specifier

  1. Default Difference b/w storage class and storage class specifier

    Hi,
    What is the difference b/w a "storage class" and "storage
    class specifier"?
    It is said that there,

    Storage Class --> automatic static ( K&R )
    Storage Class Specifier --> auto extern register static
    typedef

    What does a specifier mean? I see the name "specifier" also
    being used in

    type specifier
    struct-specifier
    union-specifier

    etc...

    Regards,
    Sarathy
    --
    comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
    have an appropriate newsgroups line in your header for your mail to be seen,
    or the newsgroup name in square brackets in the subject line. Sorry.

  2. Default Re: Difference b/w storage class and storage class specifier

    On 25 Jul 2006 10:54:46 GMT, "sarathy" <sps.sarathy@gmail.com> wrote
    in comp.lang.c.moderated:

    > Hi,
    > What is the difference b/w a "storage class" and "storage
    > class specifier"?
    > It is said that there,
    >
    > Storage Class --> automatic static ( K&R )
    > Storage Class Specifier --> auto extern register static
    > typedef


    C has three storage classes, not two: automatic, static, and
    allocated. Allocated storage only comes from calls to the memory
    management functions malloc(), calloc(), or realloc().

    All objects defined in a program therefore have either automatic or
    static storage duration.

    All objects defined at file scope, that is outside of any function,
    have static storage duration without exception.

    Objects defined inside a function have automatic storage duration by
    default, but they can be given static storage duration by use of the
    "static" keyword in their definition. You can add the keyword "auto",
    the automatic storage duration specifier, as a redundancy but it has
    no effect. Any object that can have automatic storage duration has it
    by default anyway. Example:

    void func(void)
    {
    auto int a; /* a has automatic storage duration */
    int b; /* but so does b, auto is default inside function */
    static int c; /* c has static, not automatic, duration */
    }

    The register keyword specifies the register storage duration. It may
    be applied to function arguments and objects defined inside a
    function. It is a hint and a request to the compiler, that a
    particular object might be heavily used, and a request to store it in
    a machine register or other special location that might have faster
    than normal access. The compiler is free to honor or ignore the
    request. If you define an object with the register storage class, you
    are not allowed to take its address, otherwise it is the same as the
    automatic storage class.

    Four of the five type specifiers do exactly that. When you use the
    keyword in the definition of an object, it specifies the storage
    duration that you want that object to have. Only two of them have can
    actually change the default storage class of an object, static or
    register on a block scope object that would otherwise have automatic
    storage.

    The fifth keyword, typedef, is listed as a storage class specifier, is
    lumped in with the actual specifiers for convenience. If you look at
    the C language grammar, or if you are writing a C compiler, you will
    see that the typedef keyword can appear in a declaration with a symbol
    with exactly the same syntax as a "real" storage class specifier.

    > What does a specifier mean? I see the name "specifier" also
    > being used in


    A specifier means what its ordinary English definition would suggest,
    something that specifies some feature.

    > type specifier


    When you define an object in C, it must have a type:

    int i;
    double d;

    Here the int and double keywords specify the type of the objects 'i'
    and 'd'.

    > struct-specifier
    > union-specifier


    These are the terms the standard applies to the definitions or forward
    declarations of struct and union types.

    > etc...
    >
    > Regards,
    > Sarathy


    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://c-faq.com/
    comp.lang.c++ http://www.parashift.com/c++-faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
    --
    comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
    have an appropriate newsgroups line in your header for your mail to be seen,
    or the newsgroup name in square brackets in the subject line. Sorry.

  3. Default Re: Difference b/w storage class and storage class specifier

    "sarathy" <sps.sarathy@gmail.com> writes:
    > What is the difference b/w a "storage class" and "storage
    > class specifier"?

    [...]

    This was answered in comp.lang.c over a week ago.

    Posting the same question to clc and clcm is rarely a good idea. By
    the time the question shows up in clcm, it will already have been
    answered in clc, and probably triggered a flame war or two.

    clc is good for reasonably quick answers. clcm is good for a high
    signal/noise ratio.

    --
    Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    --
    comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
    have an appropriate newsgroups line in your header for your mail to be seen,
    or the newsgroup name in square brackets in the subject line. Sorry.

+ Reply to Thread

Similar Threads

  1. return storage class and rl value specialization
    By Application Development in forum c++
    Replies: 0
    Last Post: 10-09-2007, 01:10 PM
  2. Replies: 1
    Last Post: 08-27-2007, 02:39 PM
  3. Difference b/w storage class and storage class specifier
    By Application Development in forum C
    Replies: 0
    Last Post: 07-25-2006, 05:54 AM