草庐IT

compile-time-constant

全部标签

c++ - 嵌套类显式特化 : different compiler behavior

以下代码compilesfinewithclang++6.0.0andg++7.3.0(compilationflagsare-std=c++14-Wall-Wextra-Werror-pedantic-errors)butfailstocompilewithvc++19.10.25017(compilationflagis/Za):templatestructA{templatestructB{};};templatetemplatestructA::B{staticvoidfoo();};voidA::B::foo(){}intmain(){}vc++编译错误信息:errorC29

c++ - 视觉 C++ 2008 : Finding the cause of slow link times

我有一个遗留的C++项目,它需要很长的时间来构建(几分钟,即使是小的增量更改),我发现大部分时间都花在了链接上。该项目已经在使用预编译头和增量编译。我启用了“/time”命令行参数,希望我能获得有关链接器减慢原因的更多详细信息,并获得以下输出:1>Linking...1>MDMerge:Totaltime=59.938s1>GenerateTransitions:Totaltime=0.500s1>MDFinalize:Totaltime=7.328s1>Pass1:Interval#1,time=71.718s1>Pass2:Interval#2,time=8.969s1>Final

c++ - 为什么g++ 5.4不能编译这段编译期素数代码?

#includeusingnamespacestd;templateclassPrime{//generateNprimenumbersatcompiletimepublic:unsignedintarr[N]{};constexprPrime(){intk=0;for(unsignedinti=2;ki/2)break;if(i%arr[j]==0){isPrime=false;break;}}if(isPrime)arr[k++]=i;}}};intmain(){Primeprime;//if50000->5000,okfor(auto&a:prime.arr)coutG++无法编

c++ - 命名空间与类模板名称冲突 : different compiler behavior

不同的编译器showdifferentbehavior编译以下代码:namespaceN{namespaceFoo{templatestructFoo{};}}templateusingFoo=N::Foo::Foo;namespaceN{templatestructBar:Foo{};}intmain(){}测试的编译器及其编译标志:clang++5.0.0:-std=c++14-Wall-Wextra-Werror-pedantic-errorsg++7.2:-std=c++14-Wall-Wextra-Werror-pedantic-errorsvc++19.10.25017(V

keil 报错 *** Target ‘Target 1‘ uses ARM-Compiler ‘Default Compiler Version 5‘ which is not available

问题:***Target‘Target1’usesARM-Compiler‘DefaultCompilerVersion5’whichisnotavailable.这个错误是由于使用的ARM编译器“DefaultCompilerVersion5”不可用导致。原因是新版的keil不在自动下载v5版本的编译器,但是老版本使用的v5,所以需要手动安装v5的编译器。下载v5.06的编译器并添加到keil,下载链接如下:链接:https://pan.baidu.com/s/1HKY34HP4zjkDPGd1ikbX4w?pwd=gych提取码:gych具体操作方法:(参考的是dxh_wds的资料)1.进

c++ - D8048 : cannot compile C file 'openssl\applink.c' with/ZW option

我正在尝试在我的Metro应用程序中使用OpenSSL。我创建了一个C++WinRTComponent并且在该组件下有openssl文件但是,当我尝试编译项目时,出现以下错误:D8048:无法使用/ZW选项编译C文件“openssl\applink.c”任何人都可以告诉我应该如何解决这个问题才能让我的项目编译?如果您需要任何其他信息来帮助我,请告诉我。谢谢, 最佳答案 错误消息正是它所说的-VC++不支持C++/CX扩展-使用/ZW编译器开关启用-在编译为C的文件中(这有点道理,因为这些扩展是面向对象的)。您看到这个的原因是,默认情

c++ - 获取错误 "array bound is not an integer constant before ' ]' token"

我正在尝试使用数组实现堆栈,但收到错误消息。classStack{private:intcap;intelements[this->cap];//cap=5;this->top=-1;};指示的行有这些错误:Multiplemarkersatthisline-invaliduseof'this'attoplevel-arrayboundisnotanintegerconstantbefore']'token我做错了什么? 最佳答案 在C++中,数组的大小必须是编译时已知的常量。如果不是这种情况,您将收到错误消息。在这里,你有inte

C++ typedef 和返回类型 : how to get the compiler to recognize the return type created with typedef?

#includeusingnamespacestd;classA{typedefintmyInt;intk;public:A(inti):k(i){}myIntgetK();};myIntA::getK(){returnk;}intmain(intargc,char*constargv[]){Aa(5);cout在这一行中,myInt未被编译器识别为“int”:myIntA::getK(){returnk;}如何让编译器将myInt识别为int? 最佳答案 typedef创建同义词,而不是新类型,因此myInt和int已经相同。问题

c++ - 是否有可能有 'times out' 的源代码(在某个时刻后变得无效)?

我们目前正忙于从VisualStudio2005迁移到VisualStudio2010(使用非托管C/C++)。这意味着我们大约一半的开发人员已经在使用VisualStudio2010,而另一半仍在使用VisualStudio2005。最近,我遇到了一种情况,可以在VisualStudio2010中以干净的方式编写某种构造,但是在VisualStudio2005中需要不太干净的源代码。因为并非所有开发人员的机器上都已经安装了VisualStudio2010,所以我必须编写如下代码:#if_MSC_VER>=1600//cleanversionofthesourcecode#else//

MobaXterm连接出现 Network error: Connection timed out 问题解决

MobaXterm连接出现Networkerror:Connectiontimedout:接前文:CentOS安装,点此查看文章,安装之后的SSH连接:解决思路如下:1、检查虚拟机端是否安装ssh一般情况是可以自动安装的,直接在终端输入ssh,即可进行测试,如果没有此命令的话会提示commandnotfind,需要执行如下命令进行安装:sudoyumsshinstall2、查看虚拟机的防火墙是否关闭;执行如下命令,永久是关闭防火墙:chkconfigiptablesoff如果出现不能操作的现象,可能是因为没有安装防火墙的services安装一下yuminstalliptables-servic