struct A{
constexpr A(){}
};
A a;
int main(){}
查看實時示例:Coliru和Compiler explorer。clang在Coliru中編譯此代碼段,但不在編譯器資源管理器中編譯。爲什麼?
struct A{
constexpr A(){}
};
A a;
int main(){}
查看實時示例:Coliru和Compiler explorer。clang在Coliru中編譯此代碼段,但不在編譯器資源管理器中編譯。爲什麼?
你習慣coliru以下編譯選項,而不是在編譯探險家:
-std=c++1z -O2 -Wall -pedantic -fno-elide-constructors -pthread
因爲你的代碼使用constexpr
,這裏的重要組成部分,是-std=c++1z
,使現代C++的支持(C++ 17是精確;請注意,啓用C++ 11的-std=c++11
就足夠了)。
當我在編譯器資源管理器中將該框留空時,什麼是標誌? –
他們是clang的默認值,我不知道。但是你在這裏證明了對於clang 3.9.0,默認情況下禁用C++ 11支持 – wasthishelpful
不要忘記編譯標誌https://godbolt.org/g/pWndZO – krzaq
不同的編譯器選項?像'clang ++ -std = C++ 1z'。 –
@krzaq謝謝。當我將該框留空時,什麼是默認標誌? –