I want to do this:
typedef register unsigned int _newint;
Basically, a concise alias of register unsigned int
as _newint
.
But an error, "more than one storage class may not be specified," occurs, underlining register
.
I want to know if I can do this or not; if yes then how?
I want to know if I can do this or not, if yes then how?
Both typedef
and register
count as storage classes, though that's somewhat of a technicality in the case of typedef
. You cannot declare any identifier to have more than one storage class, so the direct answer is no, you cannot do that.
You could conceivably use a macro instead of a typedef
to achieve a similar effect:
#define _newint register unsigned int
void foo() {
_newint x;
}
That is misleading, however, so you shouldn't.
More generally, you probably should not be using register
storage class at all. Modern compilers don't need your help to figure out which variables to store in registers, and register
is just a hint, so the only notable effect is that you are prevented (by rule) from taking the address of an object declared with that storage class.