-Wstrict-prototypes for extensions

From: Jeff Mitchell <quixoticsycophant@...>
Date: 2004-05-25 00:10:06 UTC
List: ruby-core #2938
It is inconvenient compiling extensions with -Wstrict-prototypes
because ruby.h and intern.h emit a slew of warnings.  This is
important because

#include <stdio.h>
int main() {
    int a = f() ;
    /* ------> a contains junk <------ */
    printf("%d\n", a) ;
}
double f() {
    return 99.0 ;
}

You will not obtain a warning if f() is defined in a different file.

I propose

#define RUBY_STRICT_PROTOTYPES
#include "ruby.h"

for extension writers wishing strict prototypes.

--- defines.h	14 Apr 2004 02:03:15 -0000	1.41
+++ defines.h	24 May 2004 23:34:49 -0000
@@ -38,7 +38,11 @@
 #ifdef __cplusplus
 #define ANYARGS ...
 #else
-#define ANYARGS
+# ifdef RUBY_STRICT_PROTOTYPES
+#  define ANYARGS void
+# else
+#  define ANYARGS
+# endif
 #endif
 
 #define xmalloc ruby_xmalloc



	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 

In This Thread

Prev Next