2017-08-30 102 views
0

私は現在Visual Studio 2008で最後にコンパイルされた古代プログラムを更新しています。最新のWindows sdk(10.0。 15063.0)しかし、gdiplusライブラリはあいまいなシンボルエラーを投げます。 具体的に:gdipluspathはcstddefとrpcndr.hのあいまいなバイトを投げる

3>c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\GdiplusPath.h(145): error C2872: 'byte': ambiguous symbol 
3>c:\program files (x86)\windows kits\10\include\10.0.15063.0\shared\rpcndr.h(191): note: could be 'unsigned char byte' 
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\cstddef(15): note: or 'std::byte' 

私はこの問題で発見した標準の試みが、残念ながら曖昧エラーがVisual Studioのことで、新しい包含によって直接私によって作られた、とされていないと仮定(私はcstddef理解するものはどれありますか?)。

どうすれば、外部ライブラリが1つのシンボル定義を使用する方向に向けることができますか?

ご協力いただきまして誠にありがとうございます。

答えて

2

最近の標準はrpcndr.hで定義されてbyteタイプと衝突します::std::byte::byteタイプの導入ため、この問題が発生します。

// cstddef 
enum class byte : unsigned char {}; 

// rpcndr.h 
typedef unsigned char byte; 

をしかし、それは、Windowsのヘッダを持つ唯一の問題ではない、彼らはまた、minmaxマクロを紹介します(gdiplusが要求しています)、<limits>の内容と衝突します。このアプローチは、ユーザコードは決して窓SDKのヘッダからbyteminmaxを使用しないことを意味していること

// global compilation flag configuring windows sdk headers 
// preventing inclusion of min and max macros clashing with <limits> 
#define NOMINMAX 1 

// override byte to prevent clashes with <cstddef> 
#define byte win_byte_override 

#include <Windows.h> // gdi plus requires Windows.h 
// ...includes for other windows header that may use byte... 

// Define min max macros required by GDI+ headers. 
#ifndef max 
#define max(a,b) (((a) > (b)) ? (a) : (b)) 
#else 
#error max macro is already defined 
#endif 
#ifndef min 
#define min(a,b) (((a) < (b)) ? (a) : (b)) 
#else 
#error min macro is already defined 
#endif 

#include <gdiplus.h> 

// Undefine min max macros so they won't collide with <limits> header content. 
#undef min 
#undef max 

// Undefine byte macros so it won't collide with <cstddef> header content. 
#undef byte 

注:

だから、この問題を回避するには、次のように、窓やGDIプラスのヘッダーが含まれている方法を制御慎重になります。

byteは他のサードパーティのライブラリと衝突する可能性があります。

+0

ありがとうございます。 minwindef.hからバイトをBYTEとして定義することで問題が解決されました。 私は自分のコードでminとmaxの定義を幸いにも制御できました。 –

関連する問題