草庐IT

alignment_of

全部标签

c++ - Qt : After installation of VS2012 LNK1123 failure during conversion to COFF

之后我安装了VS2012我的Qt项目不再编译(我的电脑上有VS2010和VS2012)。消息:LNK1123:转换为COFF期间失败:文件无效或损坏。以前只用VS2010没问题。对于VS2012环境,建议(参见SOhere):使用EnableIncrementalLinkingNO编译卸载.net4.5因为我没有将Qt与VS2012结合使用(所以没有插件),所以我不能setuptheprojectasmentioned.我也不能卸载.net4.5(另一个项目需要)。有机会解决这个问题吗?我有一些相关的问题是否可以针对VS2012C++编译器进行编译?Hereitsays为此,我需要自己

c++ - 类 std::out_of_range 在哪里完全定义?

我正在我的UbuntuLinux上的/usr/include/c++下搜索。在/usr/include/c++/stdexcept中,我发现了这个:classout_of_range:publiclogic_error{public:explicitout_of_range(conststring&__arg);};但是我在任何地方都找不到out_of_range()构造函数的定义。此外,当STL抛出out_of_range()异常时,它使用(示例取自STL_vector.h):__throw_out_of_range(__N("vector::_M_range_check"));而且

c++ - libpng 错误 : PNG unsigned integer out of range

当尝试从内存中读取PNG时,我遇到了这个奇怪的错误:libpngerror::PNGunsignedintegeroutofrange这个错误是由引起的png_read_info(png_ptr,info_ptr);它使用以下处理程序:staticvoidReadDataFromBuffer(png_structppng_ptr,png_bytepoutBytes,png_size_tbyteCountToRead){PNGDataPtrdataptr=(PNGDataPtr)png_get_io_ptr(png_ptr);png_uint_32i;coutlenpdataptr->l

c++ - boost::variant for boost::arrays of arbitrary size

我想本着的spirit创建一个boost::varianttypedefboost::variant,boost::array,boost::array,...>any_int_array;泛化为N作为模板的第二个值。换句话说,一个包含任意大小数组的boost::variant。这可能吗?请注意,在上面的示例中,boost::array是我的案例之一,但对于采用单个int的任何类,它都需要是一个可行的解决方案值作为模板参数。 最佳答案 既然你在谈论具有静态已知容量的类型,你就不能用一些模板元编程来解决这个问题吗?LiveonColi

c++ - STL 容器 move 语义并按值返回 : how many times of copying get avoided away?

我知道在C++11中,move语义已经在STL容器中实现以避免临时对象。人们说现在编写按值返回的函数是完美的。但我对究竟有多少次复制实际上被避免感到困惑。请看下面的例子:vectormyVector(){vectorres;res.push_back(4);res.push_back(5);returnres;}vectorv=myVector();我的理解是在c++03中,myVector返回res的拷贝(4,5复制了一次),在评估vectorv=myVector();时vector的复制构造函数vector(constvector&)被调用(4,5复制了两次)。但是在具有move语

c++ - 错误 : invalid use of member in static member function

我有两个类,这是其中一个的标题:#ifndefWRAPPER_HPP#defineWRAPPER_HPP#includeusingnamespacestd;classWrapper{private://SDL_Surface*screen;public:staticSDL_Surface*screen;staticvoidset_screen(SDL_Surface*_screen);staticvoidset_pixel(intx,inty,Uint8color);staticvoidclear_screen(intr,intg,intb);staticSDL_Surface*loa

c++ - 为什么在我的析构函数中抛出时总是得到 "terminate called after throwing an instance of..."?

我正在尝试编写一个单元测试来检测对我的类的lock()功能的无效使用。为此,我想使用析构函数并从那里抛出异常。不幸的是,g++没有捕获异常,而是决定调用std::terminate()。类有一个非常简化的版本:classA{public:A():f_lock(0){}~A(){if(f_lock)throwmy_exception("stilllocked");}lock(){++f_lock;}unlock(){--f_lock;}private:intf_lock;};有一个有效的测试:A*a=newA;a->lock();...a->unlock();deletea;我正在尝试编

c++ - 给定范围内的完美正方形 : abnormal execution of loops

程序编号1:在给定的a和b范围内,其中ab,我想找出一个数字是否是一个完美正方形,如果是,则打印其根。因此,我编写了如下代码:#include#include#include#includeusingnamespacestd;floatsquaredroot(intn){floatlow=0.0,mid;floathigh=(float)n+1;while((high-low)>0.00001){mid=(low+high)/2;if(mid*mid>a>>b;floatroo=0.0;for(i=a;i对于给定的输入15,输出应该是2。但是,上面的程序没有打印任何值。然而,当我尝试使

c++ - 错误 : operand out of range (64 is not between 0 and 31)

我在PowerPC上遇到GCC内联汇编。该程序使用-g2-O3编译良好,但使用-g3-O0编译失败。问题是,我需要在调试器下观察它,所以我需要没有优化的符号。程序如下:$cattest.cxx#include#undefvectortypedef__vectorunsignedcharuint8x16_p;uint8x16_pVectorFastLoad8(constvoid*p){longoffset=0;uint8x16_pres;__asm("lxvd2x%x0,%1,%2\n\t":"=wa"(res):"g"(p),"g"(offset/4),"Z"(*(constchar(

c++ - 多重继承 : size of class for virtual pointers?

给定代码:classA{};classB:publicvirtualA{};classC:publicvirtualA{};classD:publicB,publicC{};intmain(){cout输出:sizeof(D)8每个类都包含自己的虚指针,但不包含其任何基类的虚指针,那么,为什么class(D)的Size是8? 最佳答案 这取决于编译器的实现。我的编译器是VisualStdioC++2005。代码如下:intmain(){cout会输出sizeof(B):4sizeof(C):4sizeof(D):8B类只有一个虚指针