草庐IT

fno-omit-frame-pointer

全部标签

c++ - 使用 dynamic_pointer_cast 时无法动态转换

为什么这段代码不起作用?std::shared_ptre=ep->pop();std::shared_ptrt;t=std::dynamic_pointer_cast(e);我收到以下错误:/usr/include/c++/4.6/bits/shared_ptr.h:386:error:cannotdynamic_cast'(&__r)->std::shared_ptr::.std::__shared_ptr::get[with_Tp=Event,__gnu_cxx::_Lock_policy_Lp=(__gnu_cxx::_Lock_policy)2u]()'(oftype'clas

c++ - 视觉 C++ 2008 : debugging data behind pointer array

如何在VisualStudio2008中查看数组指针后面的数据而不是第一项?如果能看到任意数量的项目,而不仅仅是第一个,那将非常有用。 最佳答案 char*p=newchar[100];在监window口中输入:p,100 关于c++-视觉C++2008:debuggingdatabehindpointerarray,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/3659108/

c++ - 函数参数 : Pointer to array of objects

在我的主要功能中,我创建了一个特定类“菜单”的对象数组当我调用一个函数时,我想提供一个指向该数组的指针。Menumenu[2];//Createmenu[0],[1]Function(POINTER_TO_ARRAY);问题:函数参数的正确写法是什么?我尝试:Function(&menu);在头文件中:voidFunction(Menu*menu[]);//notworkingerror:Cannotconvertparameter1fromMenu(*)[2]toMenu*[]voidFunction(Menu*menu);//notworkingerror:Cannotconver

c++ - std::static_pointer_cast 与 static_cast<std::shared_ptr<A>>

我有一个类层次结构,其中B源自A像这样:classA:publicstd::enable_shared_from_this{};classB:publicA{voidf(){//thecodebelowcompilesstd::shared_ptrcopyOfThis=std::static_pointer_cast(shared_from_this());//thecodebelowdoesnotstd::shared_ptrcopyOfThis=static_cast>(std::make_shared(shared_from_this()));}};所以实际上我想了解为什么我不能

C++11 decltype : How to declare the type that a pointer points to?

我有以下代码:#includeintmain(){int*a=newint(2);std::unique_ptrp(a);}导致这些错误信息:Infileincludedfroma.cpp:1:Infileincludedfrom/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/memory:81:/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/

C++ is_member_pointer 实现

在c++标准库中,is_member_pointer实现为templatestruct__is_member_pointer_helper:publicfalse_type{};templatestruct__is_member_pointer_helper:publictrue_type{};///is_member_pointertemplatestructis_member_pointer:public__is_member_pointer_helper::type>::type{};有人可以解释一下_Cp是如何推导出来的吗?它像魔术一样工作。 最佳答

c++ - C 和 C++ : Array element access pointer vs int

如果您执行myarray[i]或将myarray[i]的地址存储在指针中,是否存在性能差异?编辑:这些指针都是在我的程序中一个不重要的步骤中计算出来的,性能不是标准。在关键部分,指针保持静态并且不被修改。现在的问题是这些静态指针是否比一直使用myarray[i]更快。​​ 最佳答案 对于这段代码:intmain(){inta[100],b[100];int*p=b;for(unsignedinti=0;i在g++中使用-O3优化构建时,语句:a[i]=i;产生汇编输出:mov%eax,(%ecx,%eax,4)和这个声明:*p++=

c++ - 当我尝试使用异常时,为什么我的代码在 Qt Creator 中使用 -fno-exceptions 进行编译?

在我指定的项目.pro文件中:QMAKE_CXXFLAGS+=-fno-exceptions但我能够在我的应用程序中抛出异常。对此有什么想法吗?示例:这不应该起作用,但它起作用了#include#includeintmain(intc,char**v){QApplicationapp(c,v);try{throw1;}catch(inti){}returnapp.exec();} 最佳答案 您不能通过设置QMAKE_CXXFLAGS来关闭异常,因为此选项由CONFIG处理。你应该使用CONFIG-=exceptions关闭它们。QM

c++ - "' void* ' is not a pointer-to-object type"在没有 void* 的代码中?

我的代码有问题。在Xcode或使用C++11编译器中,此代码运行良好。但是,当我将此代码提交给在线法官时,判决显示“编译错误”。我认为他们使用的是C++4.7.1编译器,当我尝试编译它(使用Ideone)时,它说:prog.cpp:Infunction'voidprintArray(int)':prog.cpp:27:error:'void*'isnotapointer-to-objecttypeprog.cpp:27:error:'void*'isnotapointer-to-objecttypeprog.cpp:27:error:'void*'isnotapointer-to-ob

c++ - 在 Mac OS X 上以多态方式捕获 -fno-rtti 共享库中的异常

我正在使用f-no-rtti构建一个共享库。在内部,此库抛出std:invalid_argument并捕获std::exception,但从未输入catch子句。以下代码重现了该问题(g++4.2、MacOSX10.6)://library.cpp:exportsf(),compiledwith-fno-rtti#include#includeextern"C"{voidf(){try{throwstd::invalid_argument("std::exceptionhandler");}catch(std::exception&e){std::cout//main.cpp:them