다음 코드는 Intel-2015에서 ok로 컴파일되지만 gcc 4.8.3에서는 실패합니다. 누가 맞습니까?인텔 대 constexpr의 GCC
#include <iostream>
void f(int const& x) { std::cout << x << std::endl; }
struct S
{
static constexpr int ce = 42;
};
int main()
{
f(S::ce);
return 0;
}
g ++ 오류 : 나는 GCC를 잘 생각
/tmp/ccOIxa2V.o: In function `main':
test_constexpr.cpp:(.text+0x36): undefined reference to `S::ce'
collect2: error: ld returned 1 exit status
GCC의 권한입니다. 's.se'하지만'std :: cout'을 사용하는 것은 맞습니다. – ForceBru
'ce'는 정적이고's :: ce'는 옳습니다. 'constexpr'와 관련이 있습니다 – user2052436
@ForceBru 도트 연산자는 유형이 아닌 객체에서 작동합니다. – chris