草庐IT

incremental-compiler

全部标签

c++ - "All memory allocated on the stack is known at compile time"是什么意思?

阅读thisgreattutorial关于堆栈与堆,我对这句话有疑问:在堆栈上分配的所有内存在编译时都是已知的。我的意思是,如果我处于取决于用户输入的for循环中(i从0到X),并且在for我在堆栈上分配内存(例如创建一些类的新实例并放入类容器中),它不知道编译程序时堆栈将如何增长(它错过了用户的输入)。我是不是误会了什么? 最佳答案 对读者来说,所做的陈述稍微简化了一点。你是对的,堆栈本质上是动态的,实际分配的数量可能因动态输入而异。这是一个带有递归函数的简单示例:voidf(intn){intx=n*10;if(x==0)ret

c++ - MSVC : what compiler switches affect the size of structs?

我有两个单独编译的DLL,一个是从VisualStudio2008编译的,一个是从matlab编译的mex文件。两个DLL都包含一个头文件。当我在一个DLL中采用sizeof()结构时,它返回48,而在另一个DLL中它返回64。我检查了/Zp开关,在两个编译中它都设置为/Zp8。还有哪些其他编译器开关可能会影响结构的大小?该结构是一个简单的POCO,没有继承,也没有虚函数。编辑结构看起来像这样:classLIBSPECSGeometry{public:std::vectorm_i;uintN;uintn_im,n_s;};在调试中,sizeof()在两种情况下都返回56,在发行版中,在

C++ 模板 : How to conditionally compile different code based on data type?

这里有一个小例子来说明我的问题的本质:#includeusingnamespacestd;typedefcharachar_t;templateclassSTRING{public:T*memory;intsize;intcapacity;public:STRING(){size=0;capacity=128;memory=(T*)malloc(capacity*sizeof(T));}constSTRING&operator=(T*buf){if(typeid(T)==typeid(char))strcpy(memory,buf);elsewcscpy(memory,buf);ret

C++ 单例用法 : compiler complains about private constructor

我知道有一百万个关于单例的问题和答案,但我似乎无法找到解决方案。所以冒着反对票的风险,这是我的问题:我想使用AndreiAlexandrescu的现代C++设计中的单例实现:标题:classSingleton{staticSingleton&Instance();private:Singleton(){};Singleton(constSingleton&){};Singleton&operator=(constSingleton&){};~Singleton(){};};实现:#include"s.hh"Singleton&Singleton::Instance(){staticSi

C++ : List iterator not incrementable

尝试删除列表的最后一个元素时出现此错误。我调试了代码并且能够找出导致它的原因和位置,这是我的代码:for(Drop_List_t::iteratori=Drop_System.begin();i!=Drop_System.end()&&!Drop_System_Disable;/**/){if(Player->BoundingBox.Intersect(&(*i)->BoundingBox)){i=Drop_System.erase(i);}++i;//Listiteratorcrasheshereiflastentrywasdeleted}我不知道我做错了什么……有什么建议吗?

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++ - 错误 "' 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