저는 alignof 연산자의 예제를 실행하려고합니다. 내가 GCC (g ++ -std = C++ 11 alignof.cpp)로 컴파일 할 때인텔 컴파일러 오류 : "alignof"식별자가 정의되지 않았습니다.
#include <iostream>
struct Empty {};
struct Foo {
int f2;
float f1;
char c;
};
int main()
{
std::cout << "alignment of empty class: " << alignof(Empty) << '\n'
<< "alignment of pointer : " << alignof(int*) << '\n'
<< "alignment of char : " << alignof(char) << '\n'
<< "alignment of Foo : " << alignof(Foo) << '\n' ;
}
나는 오류를 얻을 수 없습니다. 하지만 ICC (ICPC -std = C++ 11 alignof.cpp) 나는 다음과 같은 오류를 얻을 수 및 이유를 모르겠어요 함께 컴파일 할 때 : 나는 같은에 코드를 실행 해요
cenas.cpp(13): error: type name is not allowed
std::cout << "alignment of empty class: " << alignof(Empty) << '\n'
^
cenas.cpp(13): error: identifier "alignof" is undefined
std::cout << "alignment of empty class: " << alignof(Empty) << '\n'
^
cenas.cpp(14): error: type name is not allowed
<< "alignment of pointer : " << alignof(int*) << '\n'
^
cenas.cpp(14): error: expected an expression
<< "alignment of pointer : " << alignof(int*) << '\n'
^
cenas.cpp(15): error: type name is not allowed
<< "alignment of char : " << alignof(char) << '\n'
^
cenas.cpp(16): error: type name is not allowed
<< "alignment of Foo : " << alignof(Foo) << '\n' ;
machine, module 명령으로 컴파일러를 바꾼다. 어떻게 alignof 연산자를 정의 할 수 있습니까?
인텔 컴파일러에서 지원되는 것이 확실합니까? C++ 11 스위치를 사용하는 것이 한 가지이지만, 구현하지 않은 경우 여기에 무엇을 얻는 지 설명합니다. – Borgleader
글쎄, 그게 틀림 없어. 고맙습니다! – dspereira004