clang++

Locating iostream in Clang++: fatal error: 'iostream' file not found

五迷三道 提交于 2019-12-10 17:48:36
问题 I wrote the following simple C++ program: #include <iostream> using namespace std; int main() { cout << "Hello, World" << endl; return 0; } When I compile this with g++, it works perfectly. When I try to compile with Clang++, I get the following error: main.cpp:1:10: fatal error: 'iostream' file not found #include <iostream> ^~~~~~~~~~ 1 error generated. Running with the -v parameter, I see the following: ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../..

clang error when adding typecast in method of a template parameter

末鹿安然 提交于 2019-12-10 17:41:37
问题 I have a template struct that takes as parameters the type of a method and the pointer to a method and wraps it in a C-like function: template <typename T, T> struct proxy; template <typename T, typename R, typename ...Args, R (T::* mf)(Args...)> struct proxy<R (T::*)(Args...), mf> { static R call(T& obj, Args&&... args) { return (obj.*mf)(std::forward<Args>(args)...); } }; The proxy struct works in simple scenarios as expected, eg: struct Foo { int foo(int x) { return x + 1; } }; ... Foo f;

Clang++-3.7 CRTP compilation error “no named member” in parent's template argument

梦想与她 提交于 2019-12-10 14:59:35
问题 In the below code I am trying to use CRTP to use the static member "value" from the Child class in the Parent class. When compiling the code with g++ 5.2.1 with the "-pedantic" flag, I am able to compile as expected, and on execution both c.print_value(); and Child<int,4>::print_value(); print out 4. #include <iostream> template <typename DE> struct Parent { static const int value = DE::value; static void print_value () { std::cout << "Value : " << value << '\n'; } }; template <typename T,

std::istringstream >> to double weird behaviour

↘锁芯ラ 提交于 2019-12-10 14:36:36
问题 The following code prints 0 on mac osx with clang. Everywhere else it prints 5 (clang, gcc) #include <iostream> #include <sstream> int main() { std::istringstream iss("5C3"); double n; iss >> n; std::cout << n << std::endl; return 0; } Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) Target: x86_64-apple-darwin14.5.0 Thread model: posix When I use int it

Visual Studio 2015 build error with Clang 3.7

北慕城南 提交于 2019-12-10 14:33:52
问题 So this is a followup question to Visual Studio 2015 Update 1, clang error The error message I'm getting is clang.exe : error : cannot specify -o when generating multiple output files Basically, Hans Passant's workaround of disabling precompiled headers did not work for me. I'm still seeing the error. Anybody have any more ideas to work around this? My VS-generated command line is: -fpic -std=c++1y -fstack-protector -x c++ "Debug\" -Wall -fno-strict-aliasing -ffunction-sections -I "c:\SDKs

Clang compile error related to static_assert and boost::hana

孤者浪人 提交于 2019-12-10 13:45:28
问题 Consider the following problem which compiles successfully on Clang 3.8 using -std=c++14 . #include <boost/hana.hpp> namespace hana = boost::hana; int main() { constexpr auto indices = hana::range<unsigned, 0, 3>(); hana::for_each(indices, [&](auto i) { hana::for_each(indices, [&](auto j) { constexpr bool test = (i == (j == i ? j : i)); static_assert(test, "error"); }); }); } The test is quite non-sensical but that is not the point. Consider now an alternative version where the test is

clang is using the wrong system include directory

走远了吗. 提交于 2019-12-10 13:39:49
问题 My workstation is RHEL 6.5, which came with gcc 4.4.7 preinstalled. We are doing C++11 work, so we purchased the RedHat Developer's Toolset set of repositories, which includdes G++ 4.8.2. Both versions of G++ are installed on this machine, but 4.8.2 is the version that is invoked when launched from the command line and via a build: john@hurricane /home/john/repo/phoenix [PHX-29|✚5] $ which g++ /opt/rh/devtoolset-2/root/usr/bin/g++ john@hurricane /home/john/repo/phoenix [PHX-29|✚5] $ g++ -

Clang fails to compile template function in a template class specialization, which has *distinct return type* from the template declaration

为君一笑 提交于 2019-12-10 13:22:25
问题 The following function derefItemX() is compiled fine on GCC 4.8-5.3, but fails on CLang 3.8: //! Accessory Operations - template argument depended wrappers template<bool SIMPLE> // For Nodes / non-scoped storage struct Operations { //! \brief Defererence wrapped or direct iterator //! //! \param iel IItemXT& - iterator to be dereferenced //! \return ItemT& - resulting reference template<typename IItemXT> constexpr static auto& derefItemX(IItemXT& iel) { static_assert(is_base_of<std::forward

User-defined attributes in C++11?

孤者浪人 提交于 2019-12-10 12:55:41
问题 Is there a way to create user-defined attributes in C++11 or later? For example, [[noreturn]] void exit(); is a compiler-defined C++11 attribute. I'd like to define something like: [[comingsoon]] int function(int); Is there a mechanism for this? Edit: I should mention I'm using Clang. 回答1: The language provides no way of adding attributes. Of course, if you are using Clang, you can edit the source of Clang , and add any attributes you like. 回答2: For now it's not possible to define user

How to fix missing time related no member in global namespace errors on MacOSX?

折月煮酒 提交于 2019-12-10 12:36:51
问题 I'm trying to compile a project on the command line on Maverick 10.9. The project compiles perfectly on Linux. Apparently, there seems to be an issue with ctime on MacOSX. The errors are $ make Compiling src//core/AbstractARAClient.cpp In file included from src//core/AbstractARAClient.cpp:5: In file included from include/AbstractARAClient.h:8: In file included from include/ARAMacros.h:14: In file included from include/Address.h:9: In file included from /Applications/Xcode.app/Contents