草庐IT

STDC_CONSTANT_MACROS

全部标签

c++ - 错误 C2059 : syntax error 'constant'

这个问题在这里已经有了答案:WhyamIgetting"error:expected'}'"inC++butnotinC?(3个答案)关闭9年前。我在头文件中有以下代码:enum{false,true};我在main.c中有我的主要功能。如果我将扩展名更改为main.cpp我收到以下错误:ErrorC2059:syntaxerror'constant'我使用的是VisualC++,知道为什么吗?

C++11 统一初始化 : Field initializer is not constant

我正在尝试像这样实例化一组字符串:classPOI{public:...staticconststd::setTYPES{"restaurant","education","financial","health","culture","other"};...}现在,当我这样做时,我得到了这些错误(全部在这一行):error:fieldinitializerisnotconstantstaticconststd::setTYPES{"restaurant","education","financial","health","culture","other"};error:in-class

c++ - #include <bits/stdc++.h> 与 visual studio 不编译

这个问题在这里已经有了答案:WhyshouldInot#include?(9个回答)关闭去年。社区在8个月前审查了是否重新打开此问题,然后将其关闭:原始关闭原因未解决我最近看到#include包括每个标准库和STL包含文件。当我尝试使用visualstudio2013编译以下代码段时,它给出了errorC1083:Cannotopenincludefile:'bits/stdc++.h':Nosuchfileordirectory.但它与代码块一起工作得很好。有什么办法可以避免这个错误吗?#includeusingnamespacestd;intmain(){}我在一些帖子中看到“头文

c++ - 减少 C++(或 x-treme x-macros)中的代码重复

我在为游戏实现Lua接口(interface)时使用x-macros来减少重复和代码重复的数量Bitfighter.以下代码工作正常://FnnameValidparamprofilesProfilecount#defineTELEPORTER_LUA_METHOD_TABLE\TELEPORTER_LUA_METHOD_ITEM(addDest,ARRAYDEF({{PT,END}}),1)\TELEPORTER_LUA_METHOD_ITEM(delDest,ARRAYDEF({{INT,END}}),1)\TELEPORTER_LUA_METHOD_ITEM(clearDests

c++ - Visual Studio : C++ newline constant error

在Qt项目(使用Qt插件)上使用VisualStudio,似乎总是会抛出一条错误消息:errorC2001:newlineinconstant来自以下行:this->setApplicationVersion(QString(BUILD_VERSION));或者每当我使用在我的QMake文件中定义的编译器常量时。BUILD_VERSION在我的QMake构建配方中定义,如果我使用不同的IDE编译项目会成功(即使我使用相同的MSVC编译器,一切正常)。我想我要么在Qt插件中或在VisualStudio中缺少首选项,要么我需要在我的QMake文件等之外重新定义我的常量......常量由In

c++ - 我不明白这个 C++ 错误 - 错误 C2101 : '&' on constant

这段代码应该可以与GCC一起使用——我正试图让它与VisualStudio一起工作。我不知道代码是否真的有问题,或者我没有对端口做正确的事情。1>c:\somepath\aaa.h(52):errorC2101:'&'onconstant1>c:\somepath\aaa.h(52):whilecompilingclasstemplatememberfunction'constblahblah::Messagesomething::AClass::aMethod(void)const'1>with1>[1>Type=constlala::BClass&1>]1>c:\somepath\

c++ - 为什么我得到 "cannot allocate an array of constant size 0"?

这个问题在这里已经有了答案:WhathappensifIdefinea0-sizearrayinC/C++?(8个答案)关闭8年前。我正在为学校做一个扫雷程序,但我的代码中一直出现这个错误cannotallocateanarrayofconstantsize0我不知道为什么会这样;我没有分配大小——我将它设置为0。另一个问题是,我如何通过char读取我的输入char,这样我就可以将它保存在我的数组?正如您在下面看到的,我正在使用输入和输出。我评论了我的输入和输出,这样你们就可以看到我在这个程序中使用了什么。我想通过char读取char,这样我就可以将所有map保存在数组中。我正在使用M

c++ - 编译器优化 "constant propagation"是什么意思?

摘自ScottMeyers的EffectiveC++:templateclassSquareMatrix:privateSquareMatrixBase{public:SquareMatrix():SquareMatrixBase(n,0),pData(newT[n*n]){this->setDataPtr(pData.get());}...private:boost::scoped_arraypData;};Regardlessofwherethedataisstored,thekeyresultfromabloatpointofviewisthatnowmany—maybeall—

c++ - 海湾合作委员会 4.1.2 : error: integer constant is too large for ‘long’ type

我编译了一段关于散列函数的代码并得到了错误:整数常量对于‘long’类型来说太大了。我用谷歌搜索了一下,它说要添加后缀“ULL”,但我确实有ULL作为后缀。这个后缀只有gcc4.4.1支持,我机器上只有gcc4.1.2,不允许安装新的编译器。有什么方法可以更改代码以解决问题吗?谢谢,-托尼unsignedlonglonghash(stringk){//FNVhashunsignedlonglongx=14695981039346656037ULL;for(unsignedinty=0;y 最佳答案 1099511628211对于(3

C++ : Initializing base class constant static variable with different value in derived class?

我有一个带有常量静态变量a的基类A。我需要类B的实例对静态变量a具有不同的值。这怎么能实现,最好是静态初始化?classA{public:staticconstinta;};constintA::a=1;classB:publicA{//???//Howtoset*a*toavaluespecifictoinstancesofclassB?}; 最佳答案 你不能。所有派生类共享一个静态变量实例。 关于C++:Initializingbaseclassconstantstaticvaria