jjzjj

C++11,枚举类,g++ 的 undefined reference ,与 clang++ 一起工作

我使用了新的C++11“枚举类”类型,并在使用g++时观察到“undefinedreference”问题。这个问题不会发生在clang++中。我不知道是我做错了什么还是g++错误。重现问题的代码是:(4个文件:enum.hpp、enum.cpp、main.cpp和Makefile)//file:enum.hppenumclassMyEnum{val_1,val_2};templatestructFoo{staticconstMyEnumvalue=MyEnum::val_1;};templatestructFoo{staticconstMyEnumvalue=MyEnum::val_2

c++ - 使用 g++ 静态链接到 libcrypto++

我正在尝试使用DebianWheezy和g++4.7在我的系统上编译一个程序。我希望它能够在另一个带有DebianSqueeze的系统上运行(并且没有最近的g++)。我无法在Squeeze上编译程序,因为我使用了旧g++不支持的某些C++11功能,以及新的Boost版本和libcrypto++9。据我了解,解决此问题的常用方法是静态链接其他系统不支持的库,在我的情况下为libstdc、boost和crypto++.我现在的(链接)编译器调用是g++-4.7.obj/btcmirco.o-Wl,-Bstatic-lboost_program_options-lboost_system-l

c++ - G++:可以将 __attribute__((__may_alias__)) 用于指向类实例而不是类定义本身的指针吗?

我正在寻找以下问题的答案:may_alias是否适合作为指向某个类Foo对象的指针的属性?还是只能在类(class)级别使用?考虑以下代码(它基于更复杂的真实示例):#includeusingnamespacestd;#definealias_hack__attribute__((__may_alias__))templateclassFoo{private:/*alias_hack*/charData[sizeof(T)];public:/*alias_hack*/T&GetT(){return*((/*alias_hack*/T*)Data);}};structBar{intBaz

c++ - 全局 const 变量的 G++ 名称修饰

有人可以帮助我理解gcc名称修改约定吗?考虑下面的测试代码#includeconstintx=42;inty=42;intmain(intargc,constchar*argv[]){return0;}运行nm时,我得到以下(令人惊讶?)结果:0000000000000000Tmain0000000000000000Dy0000000000000000r_ZL1x这表明编译器只会破坏位于只读部分的全局变量。我希望编译器要么破坏所有全局变量,要么不破坏全局变量这是有意为之的行为吗?对我来说,它看起来不一致。 最佳答案 Mangling

c++ - 如何调用 clang++ 或 g++ 来准确复制两个不同标准版本中的需求

我试图确定N3337§8.5p7(C++11)和N3797§8.5p8(后C++11)之间处理值初始化的差异。N3337§8.5p7:Tovalue-initializeanobjectoftypeTmeans:ifTisa(possiblycv-qualified)classtype(Clause9)withauser-providedconstructor(12.1),thenthedefaultconstructorforTiscalled(andtheinitializationisill-formedifThasnoaccessibledefaultconstructor);

c++ - G++ 警告 : narrowing conversion of

我正在尝试从sourceforge编译hosts3d,它确实编译但生成了几个缩小错误。我不知道如何解决这个问题,但我们将不胜感激任何帮助。我怀疑我可以下载以前版本的编译器,我可能最终会这样做,但现在……c++11g++-Wall-O2-c-osrc/glwin.osrc/glwin.cppsrc/glwin.cpp:成员函数中'intMyGLWin::AddInput(int,int,unsignedint,int,constchar*,bool)':src/glwin.cpp:983:147:warning:narrowingconversionof'max'from'int'to'

c++ - clang/g++ 与私有(private)继承和使用声明的区别

考虑以下代码:#includestructParams{};templatestructBase{intdata()const{return42;}};templateclassD,classP>structMiddle:privateD//mustbe'public'forg++{};structFinal:publicMiddle{usingBase::data;};intmain(){Finalf;std::cout此代码编译成功并打印42clang并在gcc上给我编译时错误'intBase::data()const[withT=Params]'isinaccessible在这种

c++ - 我的 g++ 使用 vector<weak_ptr> erase() 方法生成奇怪的警告

我有以下C++代码:#include#include#include#includevoiderase_from_vector(std::vector>&mvec){for(automvec_it=mvec.begin();mvec_it!=mvec.end();)mvec_it=mvec.erase(mvec_it);}intmain(void){#if0std::vector>mvec;for(automvec_it=mvec.begin();mvec_it!=mvec.end();)mvec_it=mvec.erase(mvec_it);#endif}当我这样编译时,GCC会生成

AI使用 G-API 实现面部美化算法

介绍在本教程中,您将学习:示例面部美化算法的基础知识;如何使用G-API推断管道内的不同网络;如何在视频流上运行G-API管道。先决条件此示例需要:装有GNU/Linux或MicrosoftWindows的PC(支持ApplemacOS,但未经过测试);OpenCV4.2或更高版本使用英特尔®发行版OpenVINO™工具套件构建(使用英特尔®TBB构建者优先);OpenVINO™ToolkitOpenModelZoo中的以下拓扑:face-detection-adas-0001;facial-landmarks-35-adas-0002.美颜算法我们将使用现代深度学习技术和传统计算机视觉的组合

c++ - g++ 奇怪的警告

在我开始回答一个SO问题的玩具项目时,我被一个我不理解的g++警告淹没了。format.hpp:230:warning:dereferencingpointer‘’doesbreakstrict-aliasingrules在互联网上搜索我得到的印象是这可能是一个g++错误;它真的是一个错误吗?如果是,是否有任何解决方法?完整的源代码太大而无法包含,但是isavailablehere.这是触发警告的部分...templateclassValueWrapper:publicValueWrapperBase{public:Tx;ValueWrapper(constT&x):x(x){}vir