首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >英特尔编译器-错误:标识符"alignof“未定义

英特尔编译器-错误:标识符"alignof“未定义
EN

Stack Overflow用户
提问于 2013-07-15 23:18:40
回答 1查看 996关注 0票数 4
代码语言:javascript
复制
#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)编译它时,我得到了以下错误,我不知道为什么:

代码语言:javascript
复制
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' ;

我在同一台机器上运行代码,并使用module命令更改编译器。alignof运算符怎么可能是未定义的?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-15 23:22:36

不同的编译器对2011年引入的新语言功能有不同的支持。

根据this table的说法,英特尔的编译器还不支持alignof

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17657747

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档