clang++

Template template partial specialization only working with -std=c++1z with g++

纵饮孤独 提交于 2019-12-05 05:44:13
I have found that the following piece of code: #include <iostream> #include <vector> template <typename T> struct X : std::false_type {}; template <template <typename> class Y, typename U> struct X<Y<U>> : std::true_type {}; int main() { if (X<int>()) std::cout << "wrong\n"; if (X<std::vector<double>>()) std::cout << "correct\n"; return 0; } Only prints correct when compiled with g++-7 with -std=c++1z . Other versions of g++ , clang++ or other std flags fail to produce correct. Is this a bug of the current implementation, and this code should not print anything, or is something changed in C+

openssl/ssl.h not found but installed with homebrew

 ̄綄美尐妖づ 提交于 2019-12-05 03:00:44
I am working on a C++ project on my Mac running El Capitan and I get this error even after installing openssl with Homebrew: g++ -Wall -g -std=c++11 -I../libSocket/src -I../libData/src -c src/fsslhandler.cpp -o obj/fsslhandler.o In file included from src/fsslhandler.cpp:1: In file included from src/fsslhandler.h:8: ../libSocket/src/sslsocket.h:6:10: fatal error: 'openssl/ssl.h' file not found #include <openssl/ssl.h> ^ 1 error generated. make: *** [obj/fsslhandler.o] Error 1 After searching for a solution I found one which does not work : brew link openssl --force In order to make it work, I

How do I get clang to dump the AST without color?

狂风中的少年 提交于 2019-12-05 01:01:58
Using clang-check to dump a source code's AST, can be done with the following command: $ clang-check -ast-dump file.c -- However, the output of this command will appear colorful within the terminal. When I direct the output to a file, I'm stuck with all of the color escape codes: $ clang-check -ast-dump file.c -- > out.txt example: [0;1;32mTranslationUnitDecl[0m[0;33m 0x227c5c0[0m <[0;33m<invalid sloc>[0m> [0;33m<invalid sloc>[0m [0;34m|-[0m[0;1;32mTypedefDecl[0m[0;33m 0x227cac0[0m <[0;33m<invalid sloc>[0m> [0;33m<invalid sloc>[0m implicit[0;1;36m __int128_t[0m [0;32m'__int128'[0m [0;34m|-[0m

Vectorize a function in clang

六月ゝ 毕业季﹏ 提交于 2019-12-05 00:54:04
I am trying to vectorize the following function with clang according to this clang reference . It takes a vector of byte array and applies a mask according to this RFC . static void apply_mask(vector<uint8_t> &payload, uint8_t (&masking_key)[4]) { #pragma clang loop vectorize(enable) interleave(enable) for (size_t i = 0; i < payload.size(); i++) { payload[i] = payload[i] ^ masking_key[i % 4]; } } The following flags are passed to clang: -O3 -Rpass=loop-vectorize -Rpass-analysis=loop-vectorize However, the vectorization fails with the following error: WebSocket.cpp:5: WebSocket.h:14: In file

Getting clang-tidy to fix header files

非 Y 不嫁゛ 提交于 2019-12-05 00:44:48
I'm in the process of moving a project currently compiling with gcc to clang, and have a bunch of warnings that gcc didn't generate ( -Winconsistent-missing-override ). clang-tidy works for fixing these errors in the *.cpp files, however it doesn't touch the hpp files because a compile command wasn't found in the database (as I would expect). I'm using ninja to build the project and ninja -t compdb cc cxx > .build/compile_commands.json to generate the compilation database. I've tried running: clang-tidy-3.6 -p .build/ \ $(find src/ -name *.cpp) \ $(find src/ -name *.hpp) \ --checks=misc-use

Cannot view std::string when compiled with clang

大憨熊 提交于 2019-12-04 19:32:48
问题 g++ (GCC) 5.2.0 clang version 3.7.1 (tags/RELEASE_371/final) GNU gdb (GDB) 7.12 Gdb is unable to locate the definition of std::string when compiled with clang for some reason. I have custom compiled and build gcc and clang as Centos 6.5 comes with older version of gcc. Example code #include <string> int main() { std::string s("This is a string"); return 0; } Compile with g++ and debug - works just fine [~]$ g++ -ggdb3 -std=c++14 stl.cpp [~]$ gdb a.out GNU gdb (GDB) 7.12 Reading symbols from a

Forward declaration of class used in template function is not compiled by clang++

偶尔善良 提交于 2019-12-04 17:16:17
问题 There is this code: class A; template <class T> void fun() { A a; } class A { public: A() { } }; int main() { fun<int>(); return 0; } g++ 4.5 and g++ 4.7 compiles this without error. But clang++ 3.2 (trunk) gives this error: main.cpp:5:6: error: variable has incomplete type 'A' A a; ^ main.cpp:1:7: note: forward declaration of 'A' class A; ^ Which compiler is right then according to C++ standard? 回答1: Which compiler is right then according to C++ standard? Both are correct. This is an ill

“no viable conversion” with lemon for clang but valid for g++

做~自己de王妃 提交于 2019-12-04 16:25:51
Currently, I try to incorporate lemon library in our project. Most developers are on Windows, they compile with MSVC, but I am in charge (for this part) to compile with gcc and clang. I came across an error with clang that gcc does not reproduce and I managed to reduce the code: #include <lemon/dfs.h> int main() { lemon::ListDigraph g{}; lemon::ListDigraph::Node node = g.nodeFromId(42); lemon::Dfs<lemon::ListDigraph> dfs{g}; lemon::SimplePath<lemon::ListDigraph> path = dfs.path(node); return 0; } With gcc, no errors. /usr/bin/g++-5 -std=c++11 -Wall -O3 -I${SRC_ROOT}/external/lemon/latest -I$

CocoaPods: Linking with C++ symbols defined in libPods.a

删除回忆录丶 提交于 2019-12-04 14:33:52
I recently started working on a podSpec file that integrates levelDB into my projects. ( https://github.com/iljaiwas/Podspecs/blob/master/LevelDBPodSpec/0.0.1/leveldb.podspec ) However, when I reference any C++ symbol from a .mm file in the main target, I get a linker error like this: Undefined symbols for architecture x86_64: "leveldb::DB::Open(leveldb::Options const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, leveldb::DB**)", referenced from: -[IHLevelDBContext initWithPath:] in IHLevelDBContext.o This is what the compiler invocation looks

the purpose of the -Wlifetime flag?

穿精又带淫゛_ 提交于 2019-12-04 11:07:13
What is the purpose of the -Wlifetime compile flag in clang ? The information I found on the Internet about it are very vague. Is this any noticeable feature? This flag analyzes the local file to see if the code may use pointers to objects that are dead. You can see Herb Sutter cppcon video on YouTube where he explains this very well: https://youtu.be/80BZxujhY38 来源: https://stackoverflow.com/questions/52662135/the-purpose-of-the-wlifetime-flag