xiaoyin0208 / lz4

Automatically exported from code.google.com/p/lz4
0 stars 0 forks source link

lz4.h have a problem with VC++2012 #60

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. svn checkout trunk code (r88).
2. Include "lz4.h" in C++ code.
3. Compile C++ code with VC++2012.

What is the expected output? What do you see instead?

Expected: Include succeeded normally.

Instead: We got the following warning and error:

1>C:\Program Files (x86)\Microsoft Visual Studio 
11.0\VC\include\xkeycheck.h(199): warning C4005: 'inline' : macro redefinition
1>          c:\my_projects\lz4/lz4.h(45) : see previous definition of 'inline'
1>C:\Program Files (x86)\Microsoft Visual Studio 
11.0\VC\include\xkeycheck.h(242): fatal error C1189: #error :  The C++ Standard 
Library forbids macroizing keywords. Enable warning C4005 to find the forbidden 
macro.

What version of the product are you using? On what operating system?

 - lz4 (r88)
 - VC++2012 (Visual Studio Express 2012 for Windows Desktop)
 - on Windows 7 (x64)

Please provide any additional information below.

I think the problem is caused by "Breaking Changes in Visual C++".
http://msdn.microsoft.com/en-us/library/bb531344.aspx

> C++11 17.6.4.3.1 [macro.names]/2 forbids macro-izing keywords when
> C++ Standard Library headers are included.
> The headers now emit compiler errors if they detect macro-ized keywords.
> (Defining _ALLOW_KEYWORD_MACROS allows such code to compile, but we
> strongly discourage that usage.)

Only C++(11) codes are affected this change.
So, following pseudo patch will work

// lz4.h

- #ifdef _MSC_VER   // Visual Studio
+ #if defined(_MSC_VER) && !defined(__cplusplus)   // Visual Studio
  #  define inline __inline           // Visual is not C99, but supports some kind of inline
  #endif

Original issue reported on code.google.com by takayuki...@gmail.com on 10 Feb 2013 at 10:13

GoogleCodeExporter commented 8 years ago
Thanks for the very clear reporting and solution.
I'll deal with it.

Original comment by yann.col...@gmail.com on 10 Feb 2013 at 11:02

GoogleCodeExporter commented 8 years ago
The attached file is a release candidate which should solve the reported issue.
It uses your proposed correction.

Original comment by yann.col...@gmail.com on 12 Feb 2013 at 9:38

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks !
I've checked the code and there's no warnings/errors :)

Original comment by takayuki...@gmail.com on 13 Feb 2013 at 9:29

GoogleCodeExporter commented 8 years ago
Corrected into r89

Original comment by yann.col...@gmail.com on 19 Feb 2013 at 8:55