clang

Can't see Windows program's stdout in console (compiled with Clang on Windows)

夙愿已清 提交于 2020-01-23 17:32:26
问题 When I build a simple console app with clang, it works fine: void main() { puts("HELLO"); } But when I create a Windows app with WinMain , I can't see stdout. There must be a flag that fixes it, like MinGW's -mconsole 回答1: A quick stdout-enabler for otherwise GUI apps: if (AllocConsole()) { FILE* fi = 0; freopen_s(&fi, "CONOUT$", "w", stdout); } and then std::cout and printf work. 回答2: WinMain is a custom microsoft entry function for a windows graphical application (with windows and menus etc

GCC Compiler options -wno-four-char-constants and -wno-multichar

試著忘記壹切 提交于 2020-01-23 11:48:08
问题 Couldn't find any documentation on -Wno-four-char-constants , however I suspect that it is similar to -Wno-multichar . Am I correct? 回答1: They're related but not the same thing. Compiling with the -Wall --pedantic flags, the assignment: int i = 'abc'; produces: warning: multi-character character constant [-Wmultichar] with both GCC and CLANG, while: int i = 'abcd'; produces: GCC warning: multi-character character constant [-Wmultichar] CLANG warning: multi-character character constant [-Wfour

How can I find the actual Clang version on Mac?

时间秒杀一切 提交于 2020-01-23 04:54:25
问题 Note: None of the answers provided at Get Apple clang version and corresponding upstream LLVM version seems to work anymore. The download page at http://releases.llvm.org/download.html and the Wikipedia article at https://en.wikipedia.org/wiki/Clang seems to indicate that the most recent Clang version is 6.0.0. But on my macOS High Sierra version 10.13.3, I see this output: $ clang --version Apple LLVM version 9.1.0 (clang-902.0.39.1) Target: x86_64-apple-darwin17.4.0 Thread model: posix

Clang AST visitor, avoid traversing include files

本小妞迷上赌 提交于 2020-01-23 01:06:26
问题 Hello I am trying to implement an AST Clang visitor and this is my code. class ExampleVisitor : public RecursiveASTVisitor<ExampleVisitor> { private: ASTContext *astContext; // used for getting additional AST info public: virtual bool VisitVarDecl(VarDecl *var) { numVariables++; string varName = var->getQualifiedNameAsString(); string varType = var->getType().getAsString(); cout << "Found variable declaration: " << varName << " of type " << varType << "\n"; APIs << varType << ", "; return

incomplete type for std::unordered_set compiling error in g++5, compiles in clang++

我只是一个虾纸丫 提交于 2020-01-21 18:34:55
问题 Consider the code related to a previous SO question C++ cyclic dependency confusion with adjacency list representation #include <cstddef> #include <unordered_set> class Node; class Hash { public: std::size_t operator()(const Node &node) const; }; class Node { public: int data; std::unordered_set<Node, Hash> links; }; inline size_t Hash::operator()(const Node &node) const { return node.data; } int main() { } This code does not compile when using g++4.9.2 or g++5, however compiles with clang++3

`clang -ansi` extensions

ぃ、小莉子 提交于 2020-01-21 11:23:58
问题 I ran into an issue recently where the following toy example compiles cleanly using clang -ansi : int main(void) { for (int i = 0; 0; ); return i; } but gcc -ansi gives the following error: a.c: In function ‘main’: a.c:3:5: error: ‘for’ loop initial declarations are only allowed in C99 mode a.c:3:5: note: use option -std=c99 or -std=gnu99 to compile your code Compiling with clang -ansi -pedantic shows that a C99 extension is being used. a.c:3:10: warning: variable declaration in for loop is a

`clang -ansi` extensions

流过昼夜 提交于 2020-01-21 11:22:21
问题 I ran into an issue recently where the following toy example compiles cleanly using clang -ansi : int main(void) { for (int i = 0; 0; ); return i; } but gcc -ansi gives the following error: a.c: In function ‘main’: a.c:3:5: error: ‘for’ loop initial declarations are only allowed in C99 mode a.c:3:5: note: use option -std=c99 or -std=gnu99 to compile your code Compiling with clang -ansi -pedantic shows that a C99 extension is being used. a.c:3:10: warning: variable declaration in for loop is a

A 'using' statement compiles with g++, fails compilation with clang

眉间皱痕 提交于 2020-01-21 06:35:47
问题 I have code of the following structure (which is of course much more complex in reality, especially "Base" is a three-liner, but I've tried to capture the gist of it): template <class T> class A {}; template <class T> class B { public: B(){}; }; template <class T> class C : public B<A<T>> { public: using Base = B<A<T>>; using Base::B; }; static const C<int> c{}; The code compiles fine with g++ via g++ -c test.cpp -std=c++11 However, with clang++ I get an error message I don't really

A 'using' statement compiles with g++, fails compilation with clang

泄露秘密 提交于 2020-01-21 06:34:06
问题 I have code of the following structure (which is of course much more complex in reality, especially "Base" is a three-liner, but I've tried to capture the gist of it): template <class T> class A {}; template <class T> class B { public: B(){}; }; template <class T> class C : public B<A<T>> { public: using Base = B<A<T>>; using Base::B; }; static const C<int> c{}; The code compiles fine with g++ via g++ -c test.cpp -std=c++11 However, with clang++ I get an error message I don't really

gcc or clang

我怕爱的太早我们不能终老 提交于 2020-01-19 16:52:22
随着android编译由libstdc++改为了libc++,正如很早前 Android NDK 在 Changelog 中提到的那样: Everyone should be switching to Clang. GCC in the NDK is now deprecated. Android NDK 在 r17 中宣称不再支持 GCC 并在后续的 r18 中删掉 GCC. 1)GCC基于GPL,CLANG基于BSD 2)CLANG后端的LLVM(Low Level Virtual Machine)是以 BSD 许可来开发的开源的编译器框架系统,像 Swift、Rust 等语言都选择了以 LLVM 为后端 3)Freebsd也把自带编译器改用CLANG 来源: https://www.cnblogs.com/sunrisecape/p/12213995.html