2013-11-26 90 views
0

我的項目中包含以下「includes」文件。嘗試鏈接時編譯錯誤<boost property_tree json_parser.hpp>

#pragma once 

//glm 
#include <glm\glm.hpp> 
#include <glm\ext.hpp> 
#include <glm\gtc\matrix_transform.hpp> 

//glew 
#include "GL\glew.h" 

//glfw 
#define GLFW_DLL 
#include "GLFW\glfw3.h" 

//libpng 
#include <png.h> 

//std 
#include <stdio.h> 
#include <vector> 
#include <map> 
#include <stack> 
#include <queue> 
#include <list> 
#include <memory> 
#include <iostream> 
#include <fstream> 
#include <assert.h> 

//boost 
#include <boost\filesystem.hpp> 
#include <boost\property_tree\json_parser.hpp> /* problem */ 

//mandala 
#include "types.h" 
#include "type_traits.h" 
#include "hash.h" 
#include "macros.h" 

當我包括<boost\property_tree\json_parser.hpp>,我得到這表明我重新定義APIENTRY像這樣的許多錯誤:

1>c:\program files (x86)\windows kits\8.0\include\shared\minwindef.h(130): warning C4005: 'APIENTRY' : macro redefinition 

我困惑,爲什麼發生這種情況。我試圖通過在包含語句之前放置#define _MINWINDEF_來壓制minwindef.h文件的處理,但無濟於事。有沒有其他人遇到過這個問題,或者有什麼想法可以正確地包含這個提升庫?

注意

+1

你引用的是*警告*,而不是錯誤。但是,立即包含大量不同的頭文件感覺非常錯誤。您可能包含不必要的標題,或者您在該文件中實施的類中違反了SRP。或兩者。 –

+0

對不起,我有警告錯誤。還有多個宏定義會導致像'minwindef.h'這樣的錯誤聲明'near'和'far';我在代碼中廣泛使用的名稱。 –

+1

所以你包含了一些包含一些WinAPI頭文件的東西。那些定義了大量的宏,有時在不同的頭文件中甚至多於一次。你永遠不應該爲你自己的宏或變量使用這些宏名稱。我必須承認,讓我驚訝的是,'json_parser'將是包含這些頭文件而不是''filesystem'庫的庫。 –

回答

1

因爲你幾乎既沒有更新你的問題,以反映更改包括您本人,也不提供整個警告消息,我只能猜測:

你還有glfw.h包括升壓LIB之前包含WinAPI標頭。因爲當我只是谷歌的「APIENTRY重新定義」,我得到this SO question作爲第一個結果,包括答案:在glfw.h之前包含WinAPI標頭(或提升標頭包括它們)。

+0

移動glfw僅包含解決問題的相關文件。謝謝。 :) –

+0

@cmbasnett經驗教訓:請在使用SO之前先使用Google。你會經常以更快的速度獲得答案。 –

-1

你可能想也ptree包括。

#include <boost/property_tree/ptree.hpp> 
+0

以什麼方式將刪除包含WinAPI頭文件? –