Re: Delay Routine: Fully-portable C89 if possible
- From: David Brown <david@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 11 Oct 2007 11:59:47 +0200
rob windgassen wrote:
On Wed, 10 Oct 2007 09:09:43 +0200, David Brown wrote:
First the simple part - omitting the "int" part of declarations and
definitions is an abomination
That is a matter of personal taste.
In the specific case of type names like "unsigned int", it is arguably a matter of taste - although it is a general rule of programming style that it is better to be explicit than implicit. "long", for example, can be used for both "long int" and "long double" - there is no type "long" in itself.
Other implicit "int" cases in C have been gradually dropped in newer standards. For example, it used to be legal to declare a function:
extern foo();
which returns an "int", and which takes as many "int" parameters as you want. This sort of thing is not a matter of taste - it is simply bad programming style, and contrary to every attempt at safe programming.
If the proposed newer C types _Fract and _Accum become a reality, then there will be an even stronger reason to drop the implicit "int", since these will also support specified types like "unsigned short _Fract".
brought about by the terrible keyboards
K&R had to work with when developing C.
Dunno, maybe, but it is not relevant.
On closer checking, it seems that the implicit "int" comes from the language "B", but the basic reason was to minimise keystrokes (that was also the reason for allowing functions without declarations, and other such implicit or abbreviated coding).
The type in question is called
"long unsigned int" - "long" and "unsigned" are type qualifiers.
No. Unless the C-standard has changed overnight this is not true.
per section 6.7.2 of the standard all of "long", "unsigned" and "int" are called 'type-specifier' in the standard. A list of valid _sets_ of type-
specifiers is presented in that section and it includes "long" and "long int" as well "unsigned" and "unsigned int", etc.
per section 6.7.3 'type-qualifier' is defined as one of "const", "restrict" or "volatile" and nothing else.
You are correct here regarding the official C terminology - "long", etc., are "type specifiers". But they do not in themselves form types - the "int" is implied if it is missing, but it is still part of the type.
Rob.
- References:
- Delay Routine: Fully-portable C89 if possible
- From: Martin Wells
- Re: Delay Routine: Fully-portable C89 if possible
- From: David Brown
- Re: Delay Routine: Fully-portable C89 if possible
- From: Martin Wells
- Re: Delay Routine: Fully-portable C89 if possible
- From: John Devereux
- Re: Delay Routine: Fully-portable C89 if possible
- From: David Brown
- Re: Delay Routine: Fully-portable C89 if possible
- From: rob windgassen
- Delay Routine: Fully-portable C89 if possible
- Prev by Date: Re: commercial AES package
- Next by Date: Re: Delay Routine: Fully-portable C89 if possible
- Previous by thread: Re: Delay Routine: Fully-portable C89 if possible
- Next by thread: Re: Delay Routine: Fully-portable C89 if possible
- Index(es):
Relevant Pages
|