* [PATCH]-Wstrict-prototypes on SCM_FUNC_CAST_ARBITRARY_ARGS
@ 2003-12-02 15:22 Stephen Compall
2003-12-19 19:18 ` Kevin Ryde
0 siblings, 1 reply; 5+ messages in thread
From: Stephen Compall @ 2003-12-02 15:22 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 973 bytes --]
I recently added -Wstrict-prototypes to my C warning list. However,
this gives a warning for GCC 3.3.2 (at least) for both 1.6.x and HEAD,
whenever you compile the output of SCM_DEFINE et al. I fixed it by
seding 's,SCM (\*)(),SCM (\*)(void),' or something like that on the
output of guile-snarf, as strict C prototypes require (void) rather
than (), tested it with one of my native modules, and hope this will
cause no major problems in guile at large.
That is, given the semantics of ARBITRARY_ARGS, I don't think GCC will
have problems, but idiosyncratic compilers might. I'm just randomly
guessing here, by the way.
Prototypes in C++ are always strict, and anyway allow (), so I left
the C++ version as is. Patch attached.
--
Stephen Compall or s11 or sirian
A man does not look behind the door unless he has stood there himself.
-- Du Bois
diwn Ermes analyzer AMW ASDIC gamma industrial espionage Exon Shell
Mena Bosnia president CDC BROMURE SP4 terrorism
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch to libguile/snarf.h --]
[-- Type: text/x-patch, Size: 346 bytes --]
--- snarf.h.~1.62.~ 2003-11-17 20:44:04.000000000 +0000
+++ snarf.h 2003-12-02 15:11:00.000000000 +0000
@@ -32,7 +32,7 @@
#define SCM_FUNC_CAST_ARBITRARY_ARGS SCM (*)()
#else
-#define SCM_FUNC_CAST_ARBITRARY_ARGS SCM (*)()
+#define SCM_FUNC_CAST_ARBITRARY_ARGS SCM (*)(void)
#endif
/* Generic macros to be used in user macro definitions.
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH]-Wstrict-prototypes on SCM_FUNC_CAST_ARBITRARY_ARGS
2003-12-02 15:22 [PATCH]-Wstrict-prototypes on SCM_FUNC_CAST_ARBITRARY_ARGS Stephen Compall
@ 2003-12-19 19:18 ` Kevin Ryde
2003-12-20 23:50 ` Stephen Compall
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Ryde @ 2003-12-19 19:18 UTC (permalink / raw)
Cc: guile-devel
Stephen Compall <s11@member.fsf.org> writes:
>
> I recently added -Wstrict-prototypes to my C warning list. However,
> this gives a warning for GCC 3.3.2 (at least) for both 1.6.x and HEAD,
> whenever you compile the output of SCM_DEFINE et al.
Do you also get a warning from the prototypes for scm_c_define_subr
and friends (out of libguile.h)?
> I fixed it by
> seding 's,SCM (\*)(),SCM (\*)(void),' or something like that on the
> output of guile-snarf, as strict C prototypes require (void) rather
> than (), tested it with one of my native modules, and hope this will
> cause no major problems in guile at large.
I wonder why a cast is needed at all. I might have thought a
parameter "SCM (*)()" would be happly passed a function "SCM foo (SCM
x, SCM y)" or whatever.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH]-Wstrict-prototypes on SCM_FUNC_CAST_ARBITRARY_ARGS
2003-12-19 19:18 ` Kevin Ryde
@ 2003-12-20 23:50 ` Stephen Compall
2003-12-21 0:17 ` Kevin Ryde
2004-02-14 0:17 ` Kevin Ryde
0 siblings, 2 replies; 5+ messages in thread
From: Stephen Compall @ 2003-12-20 23:50 UTC (permalink / raw)
Cc: guile-devel
Kevin Ryde <user42@zip.com.au> writes:
> Do you also get a warning from the prototypes for scm_c_define_subr
> and friends (out of libguile.h)?
I added -Wstrict-prototypes to the CFLAGS for my own package, not
Guile itself. GCC, by default, does not produce warnings in system
headers (i.e. libguile.h & depends). If those functions have such
parameter types, though, missing `void' where it should be, then you
would get warnings there while compiling Guile, I should think.
Then again, the warnings I turn on would probably complain all over
the place.
> I wonder why a cast is needed at all. I might have thought a
> parameter "SCM (*)()" would be happly passed a function "SCM foo
> (SCM x, SCM y)" or whatever.
I believe this, however, would eliminate almost all the benefit of
type-checking of function pointers in the first place.
--
Stephen Compall or s11 or sirian
"But what we need to know is, do people want nasally-insertable computers?"
warfare Ft. Bragg Skipjack enforcers Medco SWAT Kennedy mania ARPA
kilo class encryption Watergate Defcon Project Monarch Ermes
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH]-Wstrict-prototypes on SCM_FUNC_CAST_ARBITRARY_ARGS
2003-12-20 23:50 ` Stephen Compall
@ 2003-12-21 0:17 ` Kevin Ryde
2004-02-14 0:17 ` Kevin Ryde
1 sibling, 0 replies; 5+ messages in thread
From: Kevin Ryde @ 2003-12-21 0:17 UTC (permalink / raw)
Cc: guile-devel
Stephen Compall <s11@member.fsf.org> writes:
>
> GCC, by default, does not produce warnings in system
> headers (i.e. libguile.h & depends).
Ah, tricky.
> If those functions have such
> parameter types, though, missing `void' where it should be, then you
> would get warnings there while compiling Guile, I should think.
Yes, except that warning isn't enabled. :)
I'd suggest putting a comment in your change about why the cast is to
"(*)(void)" where the parameter is "(*)()", in case anyone wonders
like me why they're not the same.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH]-Wstrict-prototypes on SCM_FUNC_CAST_ARBITRARY_ARGS
2003-12-20 23:50 ` Stephen Compall
2003-12-21 0:17 ` Kevin Ryde
@ 2004-02-14 0:17 ` Kevin Ryde
1 sibling, 0 replies; 5+ messages in thread
From: Kevin Ryde @ 2004-02-14 0:17 UTC (permalink / raw)
Cc: guile-devel
Stephen Compall <s11@member.fsf.org> writes:
>
> Kevin Ryde <user42@zip.com.au> writes:
> > I wonder why a cast is needed at all. I might have thought a
> > parameter "SCM (*)()" would be happly passed a function "SCM foo
> > (SCM x, SCM y)" or whatever.
>
> I believe this, however, would eliminate almost all the benefit of
> type-checking of function pointers in the first place.
I think it would let the return value get checked, which would be
advantageous, if it worked. (It'd also do what you want to be safe to
-Wstrict-prototypes.)
Casting the function pointer (as done now) means it can be anything at
all, for instance someone could mistakenly give "void" for the return
if they didn't realize it should be an SCM (and return
SCM_UNSPECIFIED).
With no cast then the return value will have to be right, though of
course since the prototype is just "()" for the args they can be
anything.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-02-14 0:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-02 15:22 [PATCH]-Wstrict-prototypes on SCM_FUNC_CAST_ARBITRARY_ARGS Stephen Compall
2003-12-19 19:18 ` Kevin Ryde
2003-12-20 23:50 ` Stephen Compall
2003-12-21 0:17 ` Kevin Ryde
2004-02-14 0:17 ` Kevin Ryde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).