Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Default type for "register" variable (http://www.velocityreviews.com/forums/t534275-default-type-for-register-variable.html)

ose 09-01-2007 07:24 PM

Default type for "register" variable
 
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++)
...
}




Robert Gamble 09-01-2007 07:34 PM

Re: Default type for "register" variable
 
On Sep 1, 3:24 pm, "ose" <os...@hotmail.com> 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


Malcolm McLean 09-01-2007 07:58 PM

Re: Default type for "register" variable
 

"Robert Gamble" <rgamble99@gmail.com> wrote in message
news:1188675285.292033.316730@57g2000hsv.googlegro ups.com...
> On Sep 1, 3:24 pm, "ose" <os...@hotmail.com> 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


Gordon Burditt 09-02-2007 12:05 AM

Re: Default type for "register" variable
 
>>> 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.



All times are GMT. The time now is 10:29 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.