草庐IT

qmake-variable-reference

全部标签

c++ - 使用静态常量初始化 unique_ptr 时出现 undefined reference 错误

当我尝试使用staticconst来初始化unique_ptr时,我收到“undefinedreference”错误。然而,当我新建一个使用相同常量的指针时,符号似乎被神奇地定义了。这是一个重现错误的简单程序:Outside_library.hclassOutside_library{public:staticconstintmy_const=100;};main.cpp#include"Outside_library.h"#include#includeclassMy_class{public:My_class(intnum){m_num=num;};virtual~My_class

C++ Qt : undefined reference to `_imp___ZN12QApplicationC1ERiPPci'

我正在尝试提醒自己一些C++,并学习Qt。我在Windows上工作。我已经安装了Qt(5.1.0)、MinGW(g++4.6.2)、GnuMake(3.81)。我正在尝试编译一个简单的Qt应用程序。最基本的情况是这样的:#include#includeintmain(intargc,char*argv[]){QApplicationapp(argc,argv);QTextStreamcout(stdout);returnEXIT_SUCCESS;}项目文件是:TEMPLATE=appTARGET=example1INCLUDEPATH+=.#InputSOURCES+=fac1.cpp

c++ - qmake:处理 gcc 和 msvc 的选项

我想制作一个可以同时使用msvc和gcc的项目文件。例如,要优化速度,您可以执行cl/O2和g++-O3。但我不知道如何告诉项目文件来产生差异。我想要这样的东西:msvc:QMAKE_CXXFLAGS_RELEASE+=/O2/openmp/arch:AVXelse:QMAKE_CXXFLAGS_RELEASE+=-O3-march=native-fopenmp-D_GLIBCXX_PARALLEL可悲的是,这不起作用。其他方法是更改​​mkspecs并将新的与我的应用程序捆绑在一起,但它不是很便携。谢谢! 最佳答案 Jean,准确

c++ - 对 __cxa_end_cleanup' 的 undefined reference

我正在尝试构建一个C++项目,但是当它完成时抛出此错误:undefinedreferenceto__cxa_end_cleanup'使用的工具链是ARMGCC4.7.3,链接器自定义标志是:-mthumb-march=armv6-m-T.\Generated_Source\PSoC4\cm0gcc.ld-g-Wl,-Map,${OutputDir}\${ProjectShortName}.map-specs=nano.specs-Wl,--gc-sections上述错误的一般原因是什么?哪些链接器标志可以解决此错误? 最佳答案 无论

c++ - "Undefined reference to"链接目标文件时出错

这个问题在这里已经有了答案:"undefinedreferenceto"errorswhenlinkingstaticClibrarywithC++code(1个回答)关闭6年前。我意识到这个问题已经以多种方式提出,包括thisverycomprehensiveanswer但我看了很多,并尝试修复我的错误,但无济于事。我正在使用.cpp和.c文件来创建程序。我用g++编译了所有文件,它似乎没有更多的链接错误,尽管它给了我一堆与C语法相关的C++错误。这是我使用的命令:g++-oprogrammain.cpp/data/*.c-l[...libs]main.cpp调用.c文件中的函数。然

c++ - 尝试与 typedef 交 friend 时出现 "elaborated type refers to typedef"错误

假设我有以下代码(一个简单的CRTP类层次结构)。我想对基类类型进行typedef以节省自己的输入(在我的实际代码中,我多次使用基类类型并且基类采用多个模板参数),并且我需要与基类交friend,因为我想保留实现私有(private)。templateclassBase{public:voidfoo(){*static_cast(this)->foo_i();}};templateclassDerived:publicBase>{public:typedefclassBase>BaseType;private://Thishereistheoffendinglinefriendclas

c++ - 为什么以不同的顺序使用 std::remove_reference 和 std::remove_const 会产生不同的结果?

在下面的代码中,我使用了std::remove_const和std::remove_reference但在两种情况下以不同的顺序给出了不同的结果:#include#include#include#include#includeusingnamespacestd;intmain(){vectorar={"mnciitbhu"};cout::type>::typeTT;cout::value::value::value::type>::typeTT;cout::value::value::value输出是:Firstcase:truefalsefalseSecondcase:falsetr

c++ - std::decay 和 std::remove_reference 之间的区别

在用C++做模板元编程的时候,经常遇到类似下面的情况:templateSmake_wrapper(T&&t){returnS(std::forward(t));}我知道我应该在返回类型中使用类似std::decay的东西,但为什么std::remove_reference不能正常工作?这里有什么区别?std::remove_cvref怎么样? 最佳答案 举个例子#includeintmain(){static_assert(std::is_same_v,std::remove_reference_t>);//int!=constin

c++ - "variable|variable"在 C++ 中是什么意思?

当我看到这个时,我正在研究这个ITE8712看门狗定时器演示代码:voidInitWD(charcSetWatchDogUnit,charcSetTriggerSignal){OpenIoConfig();//opensuperIOofconfigurationforSuperI/OSelectIoDevice(0x07);//selectdevice7//setwatchdogcounterofunitWriteIoCR(0x72,cSetWatchDogUnit|cSetTriggerSignal);//CloseIoConfig();//closesuperIOofconfigu

c++ - 带有 C++ 模板的虚假 "use of local variable with automatic storage from containing function"?

以下代码无法在g++7.2.0中编译templateclassRequest{intcontent=0;public:friendvoidsetContent(inti,void*voidptr){Request*ptr=(Request*)voidptr;ptr->content=i;}intgetContent(){returncontent;}};intmain(){Requestreq;setContent(4,&req);returnreq.getContent();}有错误test.cpp:Ininstantiationof‘voidsetContent(int,void*