【发布时间】:2011-12-22 01:12:10
【问题描述】:
所以 4251 警告至少是微软编译器的重要基础。本质上,只要您在标头定义中的任何位置使用模板类或非 dllexport 类,您都会收到此警告。更好的是,stl 中有许多类(如 map),你甚至无法摆脱这个错误,句号。
我的问题是,对于特定的课程,“#pragma 警告(禁用: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 放在导致警告的头文件中?另外,如果头文件正在被预编译,你可能需要重新编译你的预编译头文件。
标签: c++ visual-c++ visual-studio-2010