草庐IT

compiler-sfc

全部标签

C++ typedef 和返回类型 : how to get the compiler to recognize the return type created with typedef?

#includeusingnamespacestd;classA{typedefintmyInt;intk;public:A(inti):k(i){}myIntgetK();};myIntA::getK(){returnk;}intmain(intargc,char*constargv[]){Aa(5);cout在这一行中,myInt未被编译器识别为“int”:myIntA::getK(){returnk;}如何让编译器将myInt识别为int? 最佳答案 typedef创建同义词,而不是新类型,因此myInt和int已经相同。问题

c++ - Visual Studio 2015 (C++) : Stop compile on first build error (not first project)

VisualStudio2015检测到编译错误时如何停止编译?我的意思是第一次构建错误(可能是第一个.cpp),而不是第一个项目,因为它需要太多时间。(我只有1个项目。)名为"StopOnFirstBuildError"的扩展不是答案,因为它停止在有错误的第一个项目。问题(更详细)当我按下F5或Ctrl+Shift+B时,编译器会编译所有(或部分)文件。在我的例子中,它可以只用5秒检测到一些错误,所以我希望它现在停止编译。但是,VS2015变得无响应。对Ctrl+Break也有很强的抵抗力。我大约需要30秒才能导航到错误位置。如何在出现第一个编译错误时自动停止编译过程?历史有anold

C++ 函数到指针的隐式转换 : which compiler is right? Clang 和 GCC 不同意

templatestructA{};voidfunc();Aa;//sameresultwithAa;此代码使用Clang(包括最新的8.0.0)编译,但不能使用GCC(包括最新的9.1)编译。GCC说:错误:'void()'不是模板非类型参数的有效类型哪个编译器是正确的,为什么?更新我猜GCC是错误的,因为以下代码在Clang和GCC上都可以编译:templatestructA{};voidfunc();Aa;//sameresultwithAa;因此与GCC在第一个示例中的报告相反,void()似乎是“模板非类型参数的有效类型” 最佳答案

c++ - 如何为 C++ Bazel 项目生成 compile_commands.json

在C++中Bazel项目,我想使用像ClangTools这样的工具或RTags等为此我需要生成一个compile_commands.json文件。使用CMAKE_EXPORT_COMPILE_COMMANDS的CMake解决方案很简单.对于简单的Makefile,您仍然可以使用Bear工具。但是据我所知,没有针对C++Bazel项目的内置解决方案。 最佳答案 额外信息:Bear目前没有使用Bazel:thisissue可以找到有关compile_command.json的良好文档here.建议的解决方案:谷歌搜索后我找到了gist:

【报错】Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary

文章目录报错:解决方案:报错:Error:Kotlin:ModulewascompiledwithanincompatibleversionofKotlin.Thebinaryversionofitsmetadatais1.7.1,expectedversionis1.1.16.解决方案:非常简单:Build—>Rebuildproject,再运行就没问题了。如果不行可以尝试:在项目的构建文件(如pom.xml)中查找Kotlin相关的依赖或配置项,确认项目中所使用的Kotlin版本是否与代码库中的Kotlin版本一致。修改成一致后,mvnclean清理构建缓存,再重新构建即可。或者可以尝试:

c++ - <错误 C2059 : syntax error : 'constant' > when compiling with const int

编译以下代码时出现以下错误:3>c:\hedge\hedge\hedge\AisTarget.h(22):errorC2059:syntaxerror:'constant'3>c:\hedge\hedge\hedge\AisTarget.h(22):errorC2238:unexpectedtoken(s)preceding';'#if!defined(AisTarget_h)#defineAisTarget_h#include"GeneralAviationItems.h"#includenamespaceHEDGE{usingnamespaceGeneralAviation;cla

c++ - 新的 C++11 range-for (foreach) 语法 : which compilers support it?

我在thisBoostConpresentationbyJeremySiek中看到了这个c++11代码片段:dequetopo_order;topological_sort(g,front_inserter(topo_order));for(intv:topo_order){//line39cout尝试在gcc中编译时出现以下错误:main.cpp:39:error:expectedinitializerbefore‘:’token这让我想知道,哪些编译器实际上支持这种语法? 最佳答案 好吧,至少GCCsupportsitin4.6

c++ - Visual Studio 2015 : Compile C/C++ without a runtime library

有没有一种方法可以在不使用任何运行时库的情况下使用VisualStudio2015编译C/C++?我需要在没有运行时库的情况下进行编译,因为我正在创建自己的运行时库(用于我的操作系统)。在C/C++->CodeGeneration->RuntimeLibrary上有选项但我想要一个显示“无”的选项。我知道失去了CRT中的许多功能。 最佳答案 要在没有C运行时库(CRT)的情况下编译您的应用程序,请使用/MT、/NODEFAULTLIB链接器选项并在Linker->Advanced处重新定义入口点->入口点在您的代码中定义的函数,例如

c++ - 带有多个标志的 target_compile_definitions

我正在尝试更改flatbufferslibraryCMakeLists.txt使一些标志成为PUBLIC。然后,我重写了这些行:原始代码elseif(CMAKE_COMPILER_IS_GNUCXXOR"${CMAKE_CXX_COMPILER_ID}"MATCHES"Clang")set(CMAKE_CXX_FLAGS"${CMAKE_CXX_FLAGS}-std=c++0x-Wall-pedantic-Werror-Wextra")endif()新代码elseif(CMAKE_COMPILER_IS_GNUCXXOR"${CMAKE_CXX_COMPILER_ID}"MATCHES

c++ - Windows 7 和 C++ : Cross compiling application for use on Raspberry Pi

关闭。这个问题是off-topic.它目前不接受答案。想改进这个问题吗?Updatethequestion所以它是on-topic用于堆栈溢出。关闭10年前。Improvethisquestion我最近得到了一个RaspberryPi,并在上面安装了Raspbian“wheezy”镜像。我的主要开发机器运行的是Windows7,我使用QtCreator作为我的开发环境。我正在尝试找到一个工具链,我的主计算机可以使用它来为RaspberryPi编译我的C++应用程序。我到处寻找有关如何执行此操作的教程和文章,但我所能找到的只是从linux编译到windows的教程。这与我正在尝试做的相反