clang

Why doesn't clang show color output under Scons?

百般思念 提交于 2019-12-31 09:21:26
问题 When building with Scons, I can configure it to use clang like so: env["CXX"] = "clang++" However, it doesn't seem to preserve the color information that clang outputs. How can I make scons preserve the color? 回答1: According to the clang documentation, color is enabled only when a color-capable terminal is detected . SCons doesn't automatically pass on all environment variables to the process that runs the compiler, you have pass them explicitly. And TERM is not passed on to clang. Add the

What's the c++ inline class?

好久不见. 提交于 2019-12-31 08:57:12
问题 I accidentally found that the Clang compiler allows : inline class AAA { }; in C++. What's this? PS. I reported this to Clang mailing list cfe-dev@cs.uiuc.edu , and now waiting for reply. I'll update this question by I'm informed. 回答1: It's allowed in case you wish to declare a function that returns an object of that class directly after the class' declaration, for example : #include <iostream> inline class AAA { public: AAA() { // Nothing } AAA(const AAA& _Param) { std::cout << "Calling Copy

Why does declaring main as an array compile?

ぐ巨炮叔叔 提交于 2019-12-31 08:32:49
问题 I saw a snippet of code on CodeGolf that's intended as a compiler bomb, where main is declared as a huge array. I tried the following (non-bomb) version: int main[1] = { 0 }; It seems to compile fine under Clang and with only a warning under GCC: warning: 'main' is usually a function [-Wmain] The resulting binary is, of course, garbage. But why does it compile at all? Is it even allowed by the C specification? The section that I think is relevant says: 5.1.2.2.1 Program startup The function

stat() unavailable in ios simulator?

拈花ヽ惹草 提交于 2019-12-31 05:16:12
问题 I've compiled and linked ios app that uses lib (libclang) that uses stat() with no errors. But i'm having runtime error: 2014-07-07 16:55:14.138 LibClangUsage7Demo[74938:60b] started Detected an attempt to call a symbol in system libraries that is not present on the iPhone: stat$INODE64 called from function _ZN4llvm3sys2fs6statusERKNS_5TwineERNS1_11file_statusE in image LibClangUsage7Demo. LLVM code which raises error is (/Unix/Path.inc): error_code status(const Twine &Path, file_status

implicit instantiation of undefined template: Boost Bug or Clang Bug?

∥☆過路亽.° 提交于 2019-12-31 02:55:35
问题 I was trying to compile some code that uses Boost (1.49), with Clang(& libc++) from trunk. The problematic code boils down to the following: #include <memory> #include <boost/signals2.hpp> int main() { std::shared_ptr<int> s; } When compiled with Clang, the following message is emmited: $ clang++ -I/home/alexander/usr/local/include --stdlib=libc++ -std=c++0x signals2-bug.cpp -o signals2-bug signals2-bug.cpp:6:26: error: implicit instantiation of undefined template 'std::shared_ptr<int>' std:

What do Clang and GCC do when `delete`ing base classes with non-virtual destructors?

我们两清 提交于 2019-12-31 01:50:09
问题 There is already a question asking about the "real-world" behavior of delete ing a pointer to a base class that lacks a virtual destructor, but the question is restricted to a very limited case (the derived class has no members with non-trivial destructors), and the accepted answer just says there's no way to know without checking the behavior of every compiler. ....but that isn't actually very helpful; knowing that every compiler might behave differently doesn't tell us anything about the

Using array as tuple member: Valid C++11 tuple declaration?

北战南征 提交于 2019-12-31 01:05:25
问题 The code below compiles fine with G++ 4.7.2: #include <tuple> std::tuple<float,int[2]> x; With clang++ 3.2, however, the following error is produced: error: array initializer must be an initializer list. If I remove the float type from the tuple declaration, the error disappears. Is the above tuple declaration valid? ( $CXX -std=c++11 -c file.cpp ) 回答1: I don't think there is anything in the Standard that forbids your declaration. However, you will run into problems as soon as you try to

no matching constructor for initialization of 'vector<string>' with clang++ 3.2 [duplicate]

谁都会走 提交于 2019-12-30 10:44:19
问题 This question already has an answer here : Is initializer list like this legal in C++11? (1 answer) Closed 6 years ago . I'm learning c++ with C++ Primer, 5th ed.. I'm trying to compile a simple c++ program with C++11 features with clang++ but I'm getting compile errors for what should be valid code. This is an example: #include <iostream> #include <vector> #include <string> using namespace std; int main(){ int n = 0; auto *p = &n; //<-- this compiles cout << *p << endl; vector<string>

how to make clang-format add new line before opening brace of a function?

戏子无情 提交于 2019-12-30 07:57:15
问题 I'm interested in putting an opening brace for functions (but not if statements and other contexts). For example void foo() { ... } Flamewars aside, is there a good rationale for not doing this? Although I use same-line open-brackets for if/else and smaller blocks, I think in this case visual organization of larger units of code (functions/methods/classes/structs) can trump perfect consistency. Moreover, how do I get clang-format to follow this style? 回答1: As the documentation says, invoke

template template parameters and clang

与世无争的帅哥 提交于 2019-12-30 06:33:07
问题 I have had problems (possibly mine) with template template parameters and clang. The following toy example compiles and runs under g++ 4.7.0, not clang++ 3.0 (based on LLVM 3.0), both ubuntu 12.04. Toy example (test_1.cpp): #include <iostream> #include <memory> struct AFn { void operator()() { ; // do something } }; template<typename T> struct impl { T *backpointer_; }; template<typename S, template <typename> class T> struct implT { T<S> *backpointer_; }; template<typename> class AClass;