i'm trying run example of alignof operator.
#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' ; } when compile gcc (g++ -std=c++11 alignof.cpp) no errors. when compile icc (icpc -std=c++11 alignof.cpp) following errors , don't know why:
cenas.cpp(13): error: type name not allowed std::cout << "alignment of empty class: " << alignof(empty) << '\n' ^ cenas.cpp(13): error: identifier "alignof" undefined std::cout << "alignment of empty class: " << alignof(empty) << '\n' ^ cenas.cpp(14): error: type name not allowed << "alignment of pointer : " << alignof(int*) << '\n' ^ cenas.cpp(14): error: expected expression << "alignment of pointer : " << alignof(int*) << '\n' ^ cenas.cpp(15): error: type name not allowed << "alignment of char : " << alignof(char) << '\n' ^ cenas.cpp(16): error: type name not allowed << "alignment of foo : " << alignof(foo) << '\n' ; i'm running code on same machine, , change compilers module command. how can alignof operator undefined?
different compilers have different support new language features introduced in 2011.
according this table, intel's compiler not yet support alignof.
Comments
Post a Comment