clang++

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;

template template parameters and clang

被刻印的时光 ゝ 提交于 2019-12-30 06:33:06
问题 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;

How do I detect if my code is being compiled with -fno-exceptions?

旧街凉风 提交于 2019-12-30 03:06:26
问题 I'm writing a C++ library and I would like to make my API throw exceptions for invalid parameters, but rely on asserts instead when the code is compiled with -fno-exceptions . Is there a way to detect at compile-time if I'm allowed to use exception handling? Note that I'm writing a header-only library, so I don't have a configure phase and I don't have access to the build system to simply define a macro on the command line (and I don't want to add burden to the user). Since the Standard doesn

Understanding what clang is doing in assembly, decrementing for a loop that is incrementing

笑着哭i 提交于 2019-12-24 18:22:39
问题 Consider the following code, in C++: #include <cstdlib> std::size_t count(std::size_t n) { std::size_t i = 0; while (i < n) { asm volatile("": : :"memory"); ++i; } return i; } int main(int argc, char* argv[]) { return count(argc > 1 ? std::atoll(argv[1]) : 1); } It is just a loop that is incrementing its value, and returns it at the end. The asm volatile prevents the loop from being optimized away. We compile it under g++ 8.1 and clang++ 5.0 with the arguments -Wall -Wextra -std=c++11 -g -O3

Clang++ fails to locate any stdlib headers

只愿长相守 提交于 2019-12-24 12:39:29
问题 From a mac os x system I am trying to cross compile a simple C++11 program but clang++ fails to find even simple headers: test.cc #include <string> int main(int argc, char *argv[]) { return 0; } And here is the error $ clang++ --std=c++11 --stdlib=libc++ test.cc -target i386-win32 -o test clang: warning: argument unused during compilation: '--stdlib=libc++' test.cc:1:10: fatal error: 'string' file not found #include <string> ^ 1 error generated. It compiles just fine without the -target

How to intall Clang 9 on Mac?

女生的网名这么多〃 提交于 2019-12-24 10:25:32
问题 Here's what I have on my Mac: clang --version Apple LLVM version 10.0.0 (clang-1000.10.44.4) Target: x86_64-apple-darwin17.7.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin my app needs to be compiled with clang version 9, how can I install it on my Mac? I went to LLVM official site, but I don't see Clang 9 there. Any help is greatly appreciated! 回答1: I downloaded Xcode 9.2 and then did xcode-select -s /Applications/Xcode.app/Contents/Developer and then my

[LLVM-9 clang-9 OSX]: std::filesystem::path unrecognized

99封情书 提交于 2019-12-24 07:53:12
问题 Hello after upgrading on OSX Mojave to the version LLVM-9 using brew upgrade llvm I got the following error: In file included from /Users/roman/CLionProjects/Milerius/antara-gaming-sfml-template/cmake-build-debug/_deps/antara-gaming-sdk-src/modules/core/antara/gaming/core/real.path.cpp:17: /Users/roman/CLionProjects/Milerius/antara-gaming-sfml-template/cmake-build-debug/_deps/antara-gaming-sdk-src/modules/core/antara/gaming/core/real.path.hpp:23:22: fatal error: 'path' is unavailable:

g++ with std::exclusive_scan (c++17)

╄→гoц情女王★ 提交于 2019-12-24 07:18:46
问题 Is std::exclusive_scan implemented with libstdc++ ? I'm trying to use the function but I'm getting compilation error saying std::exclusive_scan is not found. Here is the sample code. With clang compiler I'm able to run the code without stdlib=libc++ option. I've included the correct header file ( <numeric> ) and compiling using std=c++17 flag. 来源: https://stackoverflow.com/questions/55771604/g-with-stdexclusive-scan-c17

g++ with std::exclusive_scan (c++17)

依然范特西╮ 提交于 2019-12-24 07:18:08
问题 Is std::exclusive_scan implemented with libstdc++ ? I'm trying to use the function but I'm getting compilation error saying std::exclusive_scan is not found. Here is the sample code. With clang compiler I'm able to run the code without stdlib=libc++ option. I've included the correct header file ( <numeric> ) and compiling using std=c++17 flag. 来源: https://stackoverflow.com/questions/55771604/g-with-stdexclusive-scan-c17

Link errors while trying to compile statically an executable with clang on windows

安稳与你 提交于 2019-12-24 04:15:10
问题 I've been trying to shift my C++ work in windows on clang lately, and everything so far seems to work right except one thing: Making full static excecutables (without any external dll dependencies like libgcc libstdc++ etc...). Let me give you an example. We have the following simple program: #include <string> int main() { std::string s1 = "Happy"; std::string s2 = " Cow"; std::string s3 = s1 + s2; return 0; } If we try to compile it using the following line: clang++ -static -O0 -std=c++11