Tag: visual c ++

为什么不允许使用静态的const float?

我有一个类本质上只是持有一堆通过我的应用程序使用的常量定义。 不过由于某种原因, long编译但是float不会: class MY_CONSTS { public : static const long LONG_CONST = 1; // Compiles static const float FLOAT_CONST = 0.001f; // C2864 }; 给出以下错误: 1>c:\projects\myproject\Constant_definitions.h(71) : error C2864: 'MY_CONSTS::FLOAT_CONST' : only static const integral data members can be initialized within a class 我错过了什么吗?

致命错误:Visual Studio中的“无目标体系结构”

当我尝试在Win32或x64模式下使用Visual Studio 2010编译我的c ++项目时,出现以下错误: >C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(135): fatal error C1189: #error : "No Target Architecture" 我的预处理器定义说WIN32; _DEBUG; _CONSOLE;%(PreprocessorDefinitions) 什么是造成这个错误,我该如何解决它? // winnt.h: lines 127-136, MSVS says this is an inactive preprocessor block #if defined(_WIN64) #if defined(_AMD64_) #define PROBE_ALIGNMENT( _s ) TYPE_ALIGNMENT( DWORD ) #elif defined(_IA64_) #define PROBE_ALIGNMENT( _s ) (TYPE_ALIGNMENT( _s ) > TYPE_ALIGNMENT( DWORD […]

/ Ox和/ O2编译器选项有什么区别?

微软的C ++编译器(包含在Visual Studio中的cl.exe )提供了几个优化开关 。 大多数的区别似乎是不言自明的,但是我不清楚/O2 (哪个优化代码为最大速度)和/Ox (哪个select“全优化”)之间的区别。 我已经尝试阅读/Ox选项的文档 ,并且似乎证实了这个开关还能够优化最大速度,而不是大小: /Ox编译器选项产生的代码优先于较小的执行速度。 但是,特别是“备注”部分下面的陈述引起了我的注意: 通常,指定/O2 (最大化速度)而不是/Ox 。 所以我的问题是, 为什么一个人应该普遍支持/O2 /Ox ? 后面的选项是否使已知的特定优化导致不可预见的错误或其他意外的行为? 简单地说,获得的优化量不值得额外的编译时间吗? 或者,这只是一个完全没有意义的“推荐”,因为/O2是VS中的默认选项?

MS C ++ 2010和mspdb100.dll

微软的C ++编译器和链接器似乎与mspdb100.dll有一个奇怪的关系。 当从IDE运行时,编译器和链接器当然可以正常工作。 从命令行运行任何一个时,我得到一个错误。 没问题,我find了DLL并将其复制到目录中。 现在编译器工作正常,但链接器死亡。 我可以通过在PATH中添加“%VS10%\ Common7 \ IDE”来解决这个问题,但是由于各种原因(性能,系统纯度,OCD等等),我不想这么做。 为什么这个设置如此敏感,还有什么我可以做的解决呢?

警告C4003和错误C2589和C2059:x = std :: numeric_limits <int> :: max();

这行在一个小testing程序中正常工作,但是在我想要的程序中,我得到了下面的编译器投诉: #include <limits> x = std::numeric_limits<int>::max(); c:\…\x.cpp(192) : warning C4003: not enough actual parameters for macro 'max' c:\…\x.cpp(192) : error C2589: '(' : illegal token on right side of '::' c:\…\x.cpp(192) : error C2059: syntax error : '::' 我得到相同的结果: #include <limits> using namespace std; x = numeric_limits<int>::max(); 为什么它将max看作macrosmax(a,b); ?

__declspec(dllimport)真的意味着什么?

我看到了这样的Qt源代码: class Q_CORE_EXPORT QBasicAtomicInt { public: … }; 哪个Q_CORE_EXPORTmacros定义如下: define Q_DECL_IMPORT __declspec(dllimport) 那么__declspec(dllimport)是什么意思?

'uint32_t'标识符未find错误

我将代码从Linux C移植到Visual C ++ for windows。 Visual c + +不知道#include <stdint.h>所以我评论它。 后来,我发现了很多'uint32_t': identifier not found错误。 如何解决?

如何写入Visual Studio中的输出窗口?

我应该使用哪个函数将文本输出到Visual Studio中的“输出”窗口? 我试过printf()但没有显示出来。

PCH警告:头文件停止不能位于macros或#if块中 – Visual C ++ 2010 Express SP1

这是从一个网站粘贴,这大概是工作。 我做了一些Googlesearch,发现我现在遇到的问题是今天下载的Visual C ++ 2010 SP1的结果,现在给我这个错误: PCH Warning: header stop cannot be in a macro or #if block. 希望有人能帮助我这个! #ifndef APP_STATE_H #define APP_STATE_H #include "Framework.h" class AppState; //this line is giving me the error //define two classes #endif Framework.h: #ifndef OGRE_FRAMEWORK_H #define OGRE_FRAMEWORK_H #include <OgreCamera.h> #include <OgreEntity.h> #include <OgreLogManager.h> #include <OgreOverlay.h> #include <OgreOverlayElement.h> #include <OgreOverlayManager.h> […]

错误LNK2005:xxx已经在MSVCRT.lib中定义(MSVCR100.dll)C:\ something \ LIBCMT.lib(setlocal.obj)

我正在使用DCMTK库来读取Dicom文件(医学image processing中使用的图像格式)。我在编译此DCMTK源代码时遇到了问题。 DCMTK使用一些额外的外部库(zlib,tiff,libpng,libxml2,libiconv)。 我知道所有库都应该使用相同的代码生成选项生成。 我已经下载了用“Multithreaded DLL”运行时选项(/ MD)编译的这些支持库的编译版本。 在DCMTK源代码的每个项目中,我确保运行时选项是“multithreadingDLL”(/ MD)。 但是我仍然得到这些错误: Error 238 error LNK2005: ___iob_func already defined in MSVCRT.lib(MSVCR100.dll) C:\dcmtk-3.5.4-src\CMakeBinaries\dcmpstat\apps\LIBCMT.lib(_file.obj) dcmp2pgm Error 239 error LNK2005: __lock_file already defined in MSVCRT.lib(MSVCR100.dll) C:\dcmtk-3.5.4-src\CMakeBinaries\dcmpstat\apps\LIBCMT.lib(_file.obj) dcmp2pgm Error 240 error LNK2005: __unlock_file already defined in MSVCRT.lib(MSVCR100.dll) C:\dcmtk-3.5.4-src\CMakeBinaries\dcmpstat\apps\LIBCMT.lib(_file.obj) dcmp2pgm Error 241 error LNK2005: __initterm_e already defined in MSVCRT.lib(MSVCR100.dll) C:\dcmtk-3.5.4-src\CMakeBinaries\dcmpstat\apps\LIBCMT.lib(crt0dat.obj) dcmp2pgm Error […]