Closed
Description
Bugzilla Link | 4513 |
Resolution | FIXED |
Resolved on | Mar 12, 2010 00:55 |
Version | unspecified |
OS | Windows XP |
Reporter | LLVM Bugzilla Contributor |
CC | @asl |
Extended Description
When compiling under MSVC, Builtin::BIalloca
is not declared. This causes CGBuiltin.cpp
to fail to compile.
The problem is that the system headers have this:
#if !__STDC__
/* Non-ANSI names for compatibility */
#define alloca _alloca
#endif /* __STDC__*/
When Builtin.h
#include
s Builtins.def
it does so with BUILTIN
defined as:
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
LIBBUILTIN
is not defined so Builtins.def
supplies a default definition:
#if defined(BUILTIN) && !defined(LIBBUILTIN)
# define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) BUILTIN(ID, TYPE, ATTRS)
#endif
Then the line
LIBBUILTIN(alloca, "v*z", "f", "stdlib.h")
expands to BI_alloca,
instead of the intended BIalloca,
This happens because LIBBUILTIN
is defined in terms of BUILTIN
. The preprocessor rescans and expands the parameter before the concat. If the line was BUILTIN(alloca, ...)
then it would work properly.
Any of the following should fix this:
- Explicitly
#undef alloca
- Change
Builtins.h
to explictly#define LIBBUILTIN
and remove the default definition fromBuiltins.def
- Change the default definition in
Builtins.def
to:
# define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) BUILTIN(##ID, TYPE, ATTRS)
but this isn't portable. I don't know if there's a portable way to stop the preprocessor from rescanning.