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

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

  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. 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. Pankaj
    Replies:
    2
    Views:
    1,024
    anupam
    Aug 23, 2004
  2. CJ
    Replies:
    1
    Views:
    1,840
    Andrew Thompson
    Oct 29, 2004
  3. Ragnar
    Replies:
    2
    Views:
    636
    tom_usenet
    Sep 4, 2003
  4. heyo
    Replies:
    3
    Views:
    1,340
    Dan Pop
    Apr 1, 2004
  5. pete
    Replies:
    4
    Views:
    1,010
    Dan Pop
    Apr 2, 2004
  6. Yevgen Muntyan

    #define ALLOCIT(Type) ((Type*) malloc (sizeof (Type)))

    Yevgen Muntyan, Feb 9, 2007, in forum: C Programming
    Replies:
    10
    Views:
    1,203
    Yevgen Muntyan
    Feb 13, 2007
  7. Nemesis

    Register with a default Value

    Nemesis, Dec 18, 2008, in forum: VHDL
    Replies:
    16
    Views:
    5,925
    Ken Cecka
    Jan 9, 2009
  8. Jan Pech
    Replies:
    7
    Views:
    866
    Nemesis
    Jan 5, 2009
Loading...