girish99 / b-tk

Automatically exported from code.google.com/p/b-tk
0 stars 0 forks source link

Guard in Utilities/stdint.h does not prevent redefinition #30

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Install MS VC++ Express Studio 2010 on a windows box
2. Configure with cmake
3. Compile with msbuild

What is the expected output? What do you see instead?
Expected compilation to proceed as on linux. Instead got compiler errors:
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\stdint.h(17): 
error C2371: 'int8_t' : redefinition; different basic types 
[C:\Users\user\Desktop\drewd\btk_build\Code\IO\BTKIO.vcxproj]                   

C:/Users/user/Desktop/drewd/win_btk/btk_win/BTK\Utilities/stdint.h(71) : see 
declaration of 'int8_t' 
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\stdint.h(25): 
error C2371: 'int_least8_t' : redefinition; different basic types 
[C:\Users\user\Desktop\drewd\btk_build\Code\IO\BTKIO.vcxproj]
          C:/Users/user/Desktop/drewd/win_btk/btk_win/BTK\Utilities/stdint.h(81) : see declaration of 'int_least8_t' 
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\stdint.h(34): 
error C2371: 'int_fast16_t' : redefinition; different basic types 
[C:\Users\user\Desktop\drewd\btk_build\Code\IO\BTKIO.vcxproj]
          C:/Users/user/Desktop/drewd/win_btk/btk_win/BTK\Utilities/stdint.h(92) : see declaration of 'int_fast16_t'
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\stdint.h(38): 
error C2371: 'uint_fast16_t' : redefinition; different basic types 
[C:\Users\user\Desktop\drewd\btk_build\Code\IO\BTKIO.vcxproj]
          C:/Users/user/Desktop/drewd/win_btk/btk_win/BTK\Utilities/stdint.h(96) : see declaration of 'uint_fast16_t'
btkANAFileIO.cpp

etc...

What version of the product are you using? On what operating system?
BTK 0.1.10 on Windows 

Please provide any additional information below.
MSVC++ defines stdint.h in c:\program files (x86)\microsoft visual studio 
10.0\vc\include\. However, its guard is _STDINT, not _MSC_STDINT_H. I was able 
to compile by adding a nested guard to Utilties/stdint.h:

#ifndef _MSC_STDINT_H
#define _MSC_STDINT_H

#ifndef _STDINT
#define _STDINT

...

#endif // _STDINT

#endif // _MSC_STDINT_H

Original issue reported on code.google.com by ddr...@gmail.com on 19 May 2012 at 5:29

GoogleCodeExporter commented 8 years ago
This issue should be fixed in the revision r1120 as recommended in the original 
project (msinttypes - http://code.google.com/p/msinttypes/issues/detail?id=10). 
Compared to the proposed fix, this has the benefit to be independant of the 
name of the guard. 

Note: This fix has not been validated as the developer doesn't have MSVC 2010.

Original comment by arnaud.barre on 19 May 2012 at 10:57

GoogleCodeExporter commented 8 years ago
A tip that might help:
I believe that MSVC 2010 is the first MS compiler that supplied its own stdint.h

Before that, it was common for libraries to supply their own stdint.h

Boost would have detected MSVC2010 and would have relied on including MS's 
stdint.h.
If, instead, it gets some other non-MS stdint.h included, then its going to 
cause chaos like this.

Look for other stdint.h files and try and move/remove them when compiling on 
MSVC2010.

Original comment by harris...@gmail.com on 7 Jun 2012 at 5:03