A few random type questions.

Doug Gwyn gwyn at smoke.ARPA
Sun Aug 28 15:32:46 AEST 1988


In article <530 at accelerator.eng.ohio-state.edu> mills at baloo.eng.ohio-state.edu (Christopher Mills) writes:
>... if I say
>	foo;
>outside of a block, I'll get a static int foo, right?

No, you're supposed to get an extern int foo (which has static storage
duration), initialized with value 0.

>	bar() { foo; }
>obviously, the compiler can't determine if I mean auto int foo, or compute
>the expression foo (I assume it assumes the latter).  This is an ambiguity
>in the grammar, yes?

Sure, the compiler can determine what to do.  You're asking it to evaluate
the expression "foo" and discard the result.  I don't know what you mean by
"ambiguity"; the reason C has lots of rules is to determine the meaning of
all valid constructs.

If you want a private variable (with scope confined to the block that is
the body of the bar() function), you must declare one.  "foo;" is not a
declaration inside a block.  The reason it works as one at the file level
is that there can be no executable code at that level.  It is not good
style in any case.

>is there any real reason for the 'auto' keyword?  Has anyone ever
>used it for anything?

"auto" is not necessary, and I don't know anyone who uses it, but I have
seen code that did, presumably to emphasize the storage class,

>is 'register int baz()' legal and if so would it make any difference anywhere.

No, a function is not in general allowed to be put into a register.
A pointer to a function is a different matter.

>What (if ever) was 'entry' used for?

It was intended for an alternate entry point to a function, as one sees
occasionally in Fortran (the canonical example being SIN and COS).
So far as I know it was never implemented anywhere.  In fact I don't
know what syntax could possibly have been intended for this.



More information about the Comp.lang.c mailing list