All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Graegert <graegerts@gmail.com>
To: "Robert P. J. Day" <rpjday@mindspring.com>
Cc: C programming list <linux-c-programming@vger.kernel.org>
Subject: Re: does static function declaration require static definition?
Date: Wed, 3 Aug 2005 10:04:45 +0200	[thread overview]
Message-ID: <6a00c8d5050803010444370ae9@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.63.0508021520360.29602@localhost.localdomain>

On 8/2/05, Robert P. J. Day <rpjday@mindspring.com> 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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2005-08-03  8:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-02 19:23 does static function declaration require static definition? Robert P. J. Day
2005-08-03  8:04 ` Steve Graegert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a00c8d5050803010444370ae9@mail.gmail.com \
    --to=graegerts@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=rpjday@mindspring.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.