Default type for "register" variable

Discussion in 'C Programming' started by ose, Sep 1, 2007.

  1. ose

    ose Guest

    When the type specifier is missing for variable "register i", what's the
    default type assumed in C?

    int redian(int Max)
    {
    register i;

    for (i = 1; i <= Max; i++)
    ...
    }
    ose, Sep 1, 2007
    #1
    1. Advertising

  2. On Sep 1, 3:24 pm, "ose" <> wrote:
    > When the type specifier is missing for variable "register i", what's the
    > default type assumed in C?
    >
    > int redian(int Max)
    > {
    > register i;
    >
    > for (i = 1; i <= Max; i++)
    > ...
    >
    > }


    The type defaults to int in C89, in C99 it is an error.

    Robert Gamble
    Robert Gamble, Sep 1, 2007
    #2
    1. Advertising

  3. "Robert Gamble" <> wrote in message
    news:...
    > On Sep 1, 3:24 pm, "ose" <> wrote:
    >> When the type specifier is missing for variable "register i", what's the
    >> default type assumed in C?
    >>
    >> int redian(int Max)
    >> {
    >> register i;
    >>
    >> for (i = 1; i <= Max; i++)
    >> ...
    >>
    >> }

    >
    > The type defaults to int in C89, in C99 it is an error.
    >

    That could be a way of getting rid of size_t. Default to a size_t in C 2007.

    --
    Free games and programming goodies.
    http://www.personal.leeds.ac.uk/~bgy1mm
    Malcolm McLean, Sep 1, 2007
    #3
  4. >>> When the type specifier is missing for variable "register i", what's the
    >>> default type assumed in C?
    >>>
    >>> int redian(int Max)
    >>> {
    >>> register i;
    >>>
    >>> for (i = 1; i <= Max; i++)
    >>> ...
    >>>
    >>> }

    >>
    >> The type defaults to int in C89, in C99 it is an error.
    >>

    >That could be a way of getting rid of size_t. Default to a size_t in C 2007.


    Why would you want to make that a default type? Why not something
    more useful, say, a function pointer? Or an array of 3 doubles?

    In any case, it's preferable to explicitly state the type, as
    otherwise you have silent breakage if the code is compiled with an
    older version of C.
    Gordon Burditt, Sep 2, 2007
    #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. CJ
    Replies:
    1
    Views:
    1,550
    Andrew Thompson
    Oct 29, 2004
  2. Nemesis

    Register with a default Value

    Nemesis, Dec 18, 2008, in forum: VHDL
    Replies:
    16
    Views:
    5,238
    Ken Cecka
    Jan 9, 2009
  3. Jan Pech
    Replies:
    7
    Views:
    653
    Nemesis
    Jan 5, 2009
  4. Peter Otten
    Replies:
    0
    Views:
    191
    Peter Otten
    Sep 5, 2012
  5. Mark Lawrence
    Replies:
    0
    Views:
    175
    Mark Lawrence
    Sep 5, 2012
Loading...

Share This Page