tedj@hpcilzb.HP.COM (Ted Johnson) (01/20/88)
I have a short L.S. C question: I have a function which is defined
as:
void myfun(x, y)
register int x, y;
{
...stuff...
}
and I tried to make a function prototype for it like this:
void myfun(register int x, register int y);
and I got the error message "invalid storage class". However when I
removed the word "register" from the prototype, it compiled. What's the
deal? Why isn't "register" a valid storage class? (I only have v.2.01
of the documentation, and this error message wasn't in it...).
Is it because prototypes just check TYPES of variables, and "register"
isn't a type, it's a storage class? But then the error message doesn't
seem to make sense.
Could someone please give me a clue? :-)
-Ted
---------------------------------------------------
Ted Johnson
Hewlett-Packard, Design Technology Center
Santa Clara, CA
(408)553-3555
UUCP: ...hplabs!hpcea!hpcilzb!tedj
tom@iconsys.UUCP (Tom Kimpton) (01/25/88)
In article <870113@hpcilzb.HP.COM> tedj@hpcilzb.HP.COM writes: > >I have a short L.S. C question: I have a function which is defined >as: > > void myfun(x, y) > register int x, y; > { > ...stuff... > } > > and I tried to make a function prototype for it like this: > > void myfun(register int x, register int y); > > > and I got the error message "invalid storage class". However when I > removed the word "register" from the prototype, it compiled. What's the > deal? Why isn't "register" a valid storage class? (I only have v.2.01 > of the documentation, and this error message wasn't in it...). > Just off the top of my head I would say that the protype is being used to check the type of the passed in object, whereas in the declaration the "register" refers to how the passed in object is used in the function, i.e. COPIED into a register and all references made to that register. Thus it doesn't make much sense (well maybe) to specify that the passed in object must be a register variable. -- Tom Kimpton {ihnp4,uunet}!iconsys!tom Icon International, Inc. {ihnp4,psivax}!nrcvax!nrc-ut!iconsys!tom Orem, Utah 84058 ARPANET: icon%byuadam.bitnet@wiscvm.wisc.edu (801) 225-6888 BITNET: icon%byuadam.bitnet