alloca cannot be a function. #define it to the gcc builtin if possible
authorRich Felker <dalias@aerifal.cx>
Mon, 9 Apr 2012 19:06:58 +0000 (15:06 -0400)
committerRich Felker <dalias@aerifal.cx>
Mon, 9 Apr 2012 19:06:58 +0000 (15:06 -0400)
gcc makes this mapping by default anyway, but it will be disabled by
-fno-builtin (and presumably by -std=c99 or similar). for the main
program the error will be reported by the linker, and the issue can
easily be fixed, but for dynamic-loaded so files, the error cannot be
detected until dlopen time, at which point it has become very obscure.

include/alloca.h

index f61b817..d2e6f1c 100644 (file)
@@ -10,6 +10,10 @@ extern "C" {
 
 void *alloca(size_t);
 
+#ifdef __GNUC__
+#define alloca __builtin_alloca
+#endif
+
 #ifdef __cplusplus
 }
 #endif