我的項目中包含以下「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
文件的處理,但無濟於事。有沒有其他人遇到過這個問題,或者有什麼想法可以正確地包含這個提升庫?
注意
你引用的是*警告*,而不是錯誤。但是,立即包含大量不同的頭文件感覺非常錯誤。您可能包含不必要的標題,或者您在該文件中實施的類中違反了SRP。或兩者。 –
對不起,我有警告錯誤。還有多個宏定義會導致像'minwindef.h'這樣的錯誤聲明'near'和'far';我在代碼中廣泛使用的名稱。 –
所以你包含了一些包含一些WinAPI頭文件的東西。那些定義了大量的宏,有時在不同的頭文件中甚至多於一次。你永遠不應該爲你自己的宏或變量使用這些宏名稱。我必須承認,讓我驚訝的是,'json_parser'將是包含這些頭文件而不是''filesystem'庫的庫。 –