jjzjj

compiler

全部标签

c++ - 如何确定请求了哪个编译器

我的项目使用SCons来管理构建过程。我想支持多个编译器,所以我决定使用AddOption,这样用户就可以在命令行上指定要使用的编译器(默认为他们当前的编译器是什么)。AddOption('--compiler',dest='compiler',type='string',action='store',default=DefaultEnvironment()['CXX'],help='Nameofthecompilertouse.')我希望能够为各种编译器提供内置编译器设置(包括特定编译器的最大警告级别等内容)。这是我目前第一次尝试的解决方案:ifis_compiler('g++'):

C++ Hello World 不工作?

我是C++的新手,我正在自学。我正在使用code::blocks,有一个问题。当我写helloworld时,什么也没有发生。这是调试器窗口中显示的内容:Buildingtoensuresourcesareup-to-dateSelectingtarget:DebugERROR:Youneedtospecifyadebuggerprograminthedebuggers'ssettings.(ForMinGWcompilers,it's'gdb.exe'(withoutthequotes))(ForMSVCcompilers,it's'cdb.exe'(withoutthequotes)

c++ - Visual Studio 2017 : _mm_load_ps often compiled to movups

我正在查看为我的代码生成的程序集(使用VisualStudio2017)并注意到_mm_load_ps经常(总是?)编译为movups。我使用_mm_load_ps的数据定义如下:structalignas(16)Vector{floatv[4];}//oftenembeddedinotherstructslikethisstructAABB{Vectormin;Vectormax;boolintersection(/*parameters*/)const;}现在,当我使用这个构造时,会发生以下情况://thiscode__mm128bb_min=_mm_load_ps(min.v);

c++ - Gtest : test compiling error

我正在尝试测试我用googletest编写的电机控制库,但我没有编译测试代码。测试位于名为test.cpp的文件中,如下所示:#include#include"../motor.hpp"TEST(constructorTest,contructorDefault){}我将测试主函数放在另一个名为main.cpp的文件中。#include#include"../motor.hpp"intmain(intargc,char*argv[]){::testing::InitGoogleTest(&argc,argv);RUN_ALL_TESTS();}为了编译,我执行了以下行:g++main.

c++ - Boost Gzip 过滤器 : compile failes

我正在尝试从BoostGzip过滤器页面编译示例:#include#include#include#include#includeintmain(){usingnamespacestd;ifstreamfile("hello.gz",ios_base::in|ios_base::binary);filtering_streambufin;in.push(gzip_decompressor());in.push(file);boost::iostreams::copy(in,cout);}遗憾的是我的g++返回错误:gzlib.cpp:Infunction‘intmain()’:gzli

urllib3 v2.0 only supports OpenSSL 1.1.1+,currently the ‘ssl‘ module is compiled with ‘OenSSL 1.1.0‘

urllib3v2.0onlysupportsOpenSSL1.1.1+,currentlythe‘ssl’moduleiscompiledwith‘OenSSL1.1.0’27mar2018环境是windows7,重新安装了OpenSSL1.1.1还是会报错;还是改urllib3的版本,不要2.0了pipinstallurllib3==1.26.15这样问题就解决了;参考原文:https://blog.csdn.net/qq_42873925/article/details/131112721

c++ - 虚拟继承的价格是多少?

这似乎是一个基本问题,但我没有看到它被问到:假设以下简单情况:没有虚拟成员。虚拟继承用于允许多个路径指向同一基。就访问最派生类的成员所需的时间而言,虚拟继承的代价是多少?特别是,如果价格不为零,它是仅适用于通过多条路径继承的成员还是也适用于其他成员? 最佳答案 Whatisthepriceofvirtualinheritanceintermsofthetimeneededtoaccessthemembersofthemostderivedclass?一个偏移查找和一个加法(2条指令和一个内存获取)Inparticular,ifthe

c++ - 错误 "' fdopen' was not declared"found with g++ 4 that compiled with g++3

我的代码可以用g++版本3.something愉快地编译。然后我想构建一些其他代码,其中包含C++11符号,所以我升级到g++4.7。现在我的原始代码无法构建。我收到错误:'fdopen'未在此范围内声明根据手册页,fdopen()在我包含的stdio.h中声明。我不确定它是否相关,但我在Cygwin环境中工作。我使用的g++的确切版本是Cygwin提供的版本4.7.2。自从我切换编译器后,我没有更改此代码,我可以肯定地确认它已构建并且我的测试代码运行并通过了以前的编译器。根据要求,演示问题的示例代码:#include#include#include#includeintmain(in

c++ - 分配给右值 : why does this compile?

在下面的例子中:classA{private:doublecontent;public:A():content(0){}Aoperator+(constA&other){content+=other.content;return*this;}voidoperator=(constA&other){content=other.content;}};A是double的简单包装器,+和=运算符已被重载。在以下使用中:intmain(intargc,char*argv[]){Aa,b,c;(a+b)=c;//Whyisthisoperationlegal?}为什么(a+b)=c可以编译?我想知

C++ 模板 : How to put nontype constraints in compiling time

假设我有以下模板templateclassFOO{....}事实上,我要求(I>=F)。如果有人误用FOOa;我希望提出一个编译错误。如何做到这一点?谢谢 最佳答案 一种方法可能是C++11的static_assert,它类似于assert,但在编译时检查:templateclassFOO{static_assert(I>=F,"IneedstobelargerorequaltoF");...}; 关于C++模板:Howtoputnontypeconstraintsincompiling