草庐IT

c++ - Clang 错误,没有可行的转换

我正面临clang3.1的问题。GCC4.2不会出现此特定问题。以下是发生错误的示例:#include#include#include#includetypedefunsignedshortchar16_t;typedefchar16_tTCHAR;typedefstd::basic_string,std::allocator>wstringT;templateinlinewstringTMyTestFunction(constT&source){std::wstringstreamout;out错误信息指出:Noviableconversionfrom'__string_type'(

c++ - 为什么 'outer inline' 模板不编译?

好的,这是一个代码:#includestructA{classType{};templateTypeas(void){std::istringstreamtest;Typetemp;test>>temp;returntemp;}};它编译正常,一点问题都没有。现在,这是几乎相同的代码:#includestructA{classType{};templateinlineTypeas(void);};templateTypeA::as(void){std::istringstreamtest;Typetemp;test>>temp;returntemp;}砰,它不再编译了。错误:t.cc:

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++ - 如何让 Clang 颜色在 boost-bjam 中工作?

b2releaselink=statictoolset=clang有效,但它没有显示我认为在clang的输出中有用的漂亮颜色。 最佳答案 免责声明:这不是解决您问题的答案,但将其放在评论中会占用太多空间。这是一个简短的Holmesian消除过程。一、根据Clangdocumentation,color仅在检测到具有颜色功能的终端时才启用。其次,根据Boost.Jamdocumentation,所有环境变量都会自动导入到其内置的.ENVIRON模块中。最后,您确实有一个支持颜色的终端。然而它不起作用。甚至使用显式Clang命令行参数来

c++ - ctor 声明/定义中接受的 const 限定符(llvm 错误?)

我的编译器(实际上是AppleLLVM5.0版(clang-500.2.79)(基于LLVM3.3svn))接受(编译)该代码:classX{private:inti;public:constX(){cout它的工作方式就好像没有const限定符引导ctor定义一样。我尝试了-Wall、-pedantic不同类型的标准激活,总是一样的......所以:我错过了什么吗?我没能发现它在最新标准中的句法是正确的……这是gcc/llvm的错误吗?似乎gcc/llvm默默地忽略了const。这是我错过的功能吗?我的示例无法证明它的用处吗?注意:gcc3.4.3不编译它,gcc4.4.5也不编译。

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++ - LLVM 中间表示 : fptoui vs. fptosi

我无法理解LLVM-IR指令“fptosi...to”和“fptoui...to”之间的区别。我写了一个示例程序来更好地理解这些指令的语义。#includeintmain(intargc,char**argv){doubled=-3.5-4;unsignedintui=(unsignedint)d;intsi=(int)d;printf("unsigned%u,0x%x\n",ui,ui);printf("signed%i,0x%x\n",si,si);return0;}正如预期的那样,clang生成了这两种指令...%5=fptouidouble%4toi32storei32%5,i

c++ - 将 OSX Clang 配置为对 include 语句区分大小写

我知道C++include语句中区分大小写是一个文件系统问题(相关问题here和here)。是否可以将Clang配置为要求区分大小写的匹配以防止跨平台构建问题? 最佳答案 Clang现在有这些警告标志:-Wnonportable-include-path-Wnonportable-system-include-path第一个用于引用包含,第二个用于尖括号包含。它们甚至可以映射到错误:-Werror=nonportable-include-path-Werror=nonportable-system-include-path据推测,默

clang 中的 C++ 结构内存开销?

clang中是否存在每个结构的内存开销?通常结构的大小只是其所有成员的总大小。但是在clang中似乎不是这样:#includeusingnamespacestd;structObj{intx;inty;};intmain(){inta=42;intb=43;Objobj={100,101};intc=44;cout我用clang++program.cpp编译,没有优化。版本:Ubuntuclangversion3.4-1ubuntu3(tags/RELEASE_34/final)(basedonLLVM3.4)Target:x86_64-pc-linux-gnuThreadmodel:

c++ - 是否有可能从 gcc 或 clang 获得 Lexer 输出?

是否可以让clang或gcc显示词法分析阶段的结果? 最佳答案 虽然解析器doespollthelexer如果没有适当的“词法分析阶段”,这并不意味着您不能在词法分析时转储token。这是通过命令完成的:clang-fsyntax-only-Xclang-dump-tokenscode.c 关于c++-是否有可能从gcc或clang获得Lexer输出?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/