[llvm-commits] [PATCH] Fix bug with _MSC_VER define

Bob Wilson bob.wilson at apple.com
Tue Sep 4 10:50:04 PDT 2012


On Aug 31, 2012, at 5:29 PM, Chris Lattner <clattner at apple.com> wrote:

> On Aug 30, 2012, at 11:21 AM, John Garvin <jgarvin at apple.com> wrote:
>> This patch makes sure preprocessor macros in the include subdirectory are not used without being defined. This adds to the previous patch, which only made this change for the _MSC_VER macro.
>> 
>> Rationale: For each preprocessor macro, either the definedness is what's meaningful, or the value is what's meaningful, or both. If definedness is meaningful, we should use #ifdef. If the value is meaningful, we should use #if and it should be an error if it's undefined. If both, we should ask #ifdef and then ask about the value. Mixing up these cases, e.g., using #if and #ifdef interchangeably for the same macro, seems ugly to me, even if undefined macros are zero if used.
>> 
>> This also has the benefit that including an LLVM header doesn't prevent you from compiling with -Wundef -Werror.
>> 
>> In more detail:
>> _MSC_VER: change "#if _MSC_VER > number" to "#if defined(_MSC_VER) && _MSC_VER > number". This matches the other uses of _MSC_VER which are used in a context where the macro must be defined.
>> DEBUG, HAVE_SYS_STAT_H, and LLVM_ON_WIN32: change one use of #if to #ifdef. This is to match the #ifdef's in the rest of the code. HAVE_SYS_STAT_H is either #define'd or #undef'd by configure, so it should be #ifdef. The docs say to use #ifdef LLVM_ON_WIN32.
>> 
>> Does this make sense? What do you think?
> 
> This patch looks fine to me.

I've applied it in svn r163148.



More information about the llvm-commits mailing list