On 8/2/05, Robert P. J. Day <[EMAIL PROTECTED]> wrote:
> 
>  from my 5th edition of harbison and steele, p. 83, i read that the
> "static" storage class specifier on a function "indicates that the
> declared function will be defined -- with storage class static --
> later in the file."
> 
>  doesn't this read that, once you declare the function as static, you
> *must* define it as static as well?  gcc doesn't seem to have a
> problem with leaving "static" off of the definition.

For GCC it should be sufficient to declare a function as static and
omit the static keyword in the definition (but I prefer to see it in
both, declarations and definitions):

        /* declaration */
        static void func(int, int);
        
        /* definition */
        void func(int a, int b) {
                /* do some work here */
        }

Please note that static functions are only visible to other functions
in the same translation unit.  Also note that C99 (p. 141 ยง4) says:

"The storage-class specifier, if any, in the declaration specifiers
shall be either extern or static."

The static keyword is optional in function definitions.

Regards

       \Steve
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" 
in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to