因此,4251警告至少是微軟編譯器的嚴重基礎。從本質上講,任何時候您在標題定義中的任何地方使用模板類或非dllexport類時都會得到此警告。更好的是,stl中有很多類(比如地圖),你甚至無法擺脫這個錯誤。爲什麼MSVC10忽略我的#pragma警告(禁用:4251)?
我的問題是,對於特定的類,「#pragma warning(disable:4251)」只是平坦的不起作用。它在其他地方工作,但在這裏。
DelWestInspectionProgram.cpp
#include "stdafx.h"
#pragma warning(disable: 4251)
...
Output Log:
E:\svn\VisionNow\VisionSuite\VI.Inspector.ImageProcessing.Common\BIImage.h(79): warning C4251: 'BIImage::_data' : class 'boost::shared_array<T>' needs to have dll-interface to be used by clients of class 'BIImage'
6> with
6> [
6> T=unsigned char
6> ]
6>E:\svn\VisionNow\VisionSuite\VI.Inspector.ImageProcessing.Operators\BIImageOperator.h(25): warning C4251: 'BIImageOperator::_savePath' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'BIImageOperator'
6> with
6> [
6> _Elem=char,
6> _Traits=std::char_traits<char>,
6> _Ax=std::allocator<char>
6> ]
任何幫助將不勝感激。
你把#pragma放在引起警告的頭文件中嗎?此外,如果正在編譯頭文件,則可能需要重新編譯預編譯頭。 – 2011-12-22 01:54:23