Article View: comp.std.c
Article #4077Re: Function-prototype scope: Why?
From: halasz
Date: Fri, 22 Sep 1995 00:32
Date: Fri, 22 Sep 1995 00:32
43 lines
2370 bytes
2370 bytes
There is a grave misunderstanding here: at no time in my part of this
discussion referrd I to the use of f-p scope in generating right code,
nor will I. I referrd to its use in rejecting source-code when a call
entails passing a pointer about which not enough is known. My examples
bear onlie on that. As for the grounds for seeking such behavior, I
suggest the lack of that guarantee of safetie suppozedlie afforded by
fullie declaring all parameters.
But I hav thought of more examples, that this explanation explains not.
There is nothing wrong with generating the same code for "j" and "js",
and "k" and "ks",
struct
{ char l;
} js, *ks;
char j, *k;
but another has posted that the standard requires "ks" to hav the same
"shape" as this "fs":
struct
{ float m;
} *fs;
. That is, all 'struct'-pointers shall hav the same "shape".
Therefore, the compiler has no pointer-code-trouble with this:
int k(struct S *);
. Furthermore, if the latter foregoind 'struct' is 'struct S', and the
programmer passes a pointer to the former 'struct', the compiler, it seems,
is permitted to generate code and warning, even though this can lead to
bus error on processors that hav require stricter alignment for the latter
than the former--and a cast makes the warning go awai.
As for the older C, there is no safetie-guarantee in
argument-passing. Promotion is nothing more than a hack that
makes not declaring the parameters slightlie safer.
In article <43rqp8$6pc@rdsunx.crd.ge.com>, volpe@bart.crd.ge.com (Christopher R. Volpe) writes:
> ....
> Of course, as I said before, f-p scope is useful for one thing: being able to
> have header files with comprehensible prototypes like:
>
> int foobar(int window, float color);
>
> without corrupting the user's namespace with identifiers "window" and
If that is so, it is no more than a bad hack, unless it also permits
information-hiding, but C needs much more for that to work.
Technical Details
Message-ID:
<43t07j$q19@caip.rutgers.edu>Path:
arc1-ca.pugleaf.net!caip.rutgers.edu!not-for-mailReferences:
<43cgmb$cec@news0.rain.rg.net> <43er80$458@caip.rutgers.edu> <43rqp8$6pc@rdsunx.crd.ge.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!caip.rutgers.edu!not-for-mail From: halasz@caip.rutgers.edu Newsgroups: comp.std.c Subject: Re: Function-prototype scope: Why? Date: 21 Sep 1995 20:32:51 -0400 Organization: Rutgers University Message-ID: <43t07j$q19@caip.rutgers.edu> References: <43cgmb$cec@news0.rain.rg.net> <43er80$458@caip.rutgers.edu> <43rqp8$6pc@rdsunx.crd.ge.com> NNTP-Posting-Host: caip.rutgers.edu