5
我想編譯一個真正簡單的線程程序在我的Linux機器上(ubuntu),但鏗鏘似乎仍然拋出一個錯誤,即使當我指定libC++。我的計劃是:表達式不是一個整數常量叮噹libC++線程
#include <iostream>
#include <thread>
void call_from_thread() {
std::cout << "Hello, World!" << std::endl;
}
int main()
{
std::thread t1(call_from_thread);
t1.join();
return 0;
}
生成文件:
CC=clang++
CFLAGS=-std=c++11 -stdlib=libc++ -pthread -c -Wall
#proper declaration of libc++, but still an error...
LDFALGS=
SOURCES=main.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=bimap
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o [email protected]
.cpp.o:
$(CC) $(CFLAGS) $< -o [email protected]
特定的錯誤:
In file included from main.cpp:2:
In file included from /usr/include/c++/4.6/thread:37:
/usr/include/c++/4.6/chrono:666:7: error: static_assert expression is not an
integral constant expression
static_assert(system_clock::duration::min()
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [main.o] Error 1
鐺爲什麼不使用的libC++我不知道,因爲如果我沒有弄錯,clang會使用這個庫來編譯線程。任何幫助表示讚賞!
也許向我們展示clang提供的錯誤。 – hetepeperfan
你錯誤地拼寫了'LDFLAGS'。 – kennytm
請注意,這是一個已知問題。 [LLVM報告](http://llvm.org/bugs/show_bug.cgi?id=12893),[Ubuntu報告](https://bugs.launchpad.net/ubuntu/+source/clang/+bug/1081905) ),[Debian報告](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=666539),[Clang郵件列表](http://lists.cs.uiuc.edu/pipermail/cfe -dev/2011六月/ 015641.html) – Albert