home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!wupost!uwm.edu!ogicse!das-news.harvard.edu!spdcc!dirtydog.ima.isc.com!karl
- From: karl@ima.isc.com (Karl Heuer)
- Newsgroups: comp.std.c
- Subject: Re: Scope of arguments in prototype
- Keywords: scope, prototypes
- Message-ID: <1992Sep15.224805.9790@ima.isc.com>
- Date: 15 Sep 92 22:48:05 GMT
- References: <1992Sep14.225546.4277@xilinx.com>
- Sender: usenet@ima.isc.com (news)
- Organization: Interactive Systems, Cambridge, MA 02138-5302
- Lines: 24
-
- In article <1992Sep14.225546.4277@xilinx.com> lou@xilinx.com (Lou Sanchez-Chopitea) writes:
- >Hi,
- > What is the scope of the arguments in a prototype? In particular do I have
- >to worry about "a" and "b" in:
- > double func ( double a, int b);
- >if it is a header file, conflicting with variables a user might wish to define?
-
- Identifiers declared as formal arguments in a prototype declaration have very
- short scope, so in that sense you're safe. (This fact does cause problems if
- you try to declare something like
- extern char *asctime(struct tm const *);
- since the short scope prevents this from serving as the first declaration of
- the struct tag; for this reason it's necessary to put the struct declaration
- before the prototype, or at least predeclare the tag with
- struct tm;
- to establish a scope.)
-
- However, there's a different danger: the header may exhibit incorrect behavior
- if the user, before including the header, has defined a *macro* with the name
- |a| or |b|. For this reason, it's better to leave out the identifiers in
- declaration prototypes, or use names that are within your documented
- namespace. ("__a" works if this is part of the standard library.)
-
- Karl W. Z. Heuer (karl@ima.isc.com or uunet!ima!karl), The Walking Lint
-