的std :: ALIGN不支持的G ++ 4.9 [英] std::align not supported by g++4.9

查看:391
本文介绍了的std :: ALIGN不支持的G ++ 4.9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在学习有关对齐的问题等等,我意识到,我的实现G ++ 4.9(MacPorts的OS X)不具有的std ::对齐支持。如果我尝试编译(用 -std = C ++ 11 )的<一个这个例子code href="http://www.cplusplus.com/reference/memory/align/">http://www.cplusplus.com/reference/memory/align/

While learning about alignment issues etc, I realized that my implementation of g++4.9 (macports OS X) does not have support for std::align. If I try to compile (with -std=c++11) this example code from http://www.cplusplus.com/reference/memory/align/

// align example
#include <iostream>
#include <memory>

int main() {
  char buffer[] = "------------------------";
  void * pt = buffer;
  std::size_t space = sizeof(buffer)-1;
  while ( std::align(alignof(int),sizeof(char),pt,space) ) {
    char* temp = static_cast<char*>(pt);
    *temp='*'; ++temp; space-=sizeof(char);
    pt=temp;
  }
  std::cout << buffer << '\n';
  return 0;
}

编译器吐出来的是错误

the compiler spits out the error

error: 'align' is not a member of 'std'

这似乎很奇怪的G ++似乎因为G ++ 4.8, HTTPS来已经实现对齐支持://gcc.gnu。组织/项目/ cxx0x.html (N2341)

This seems strange as g++ seems to have implemented alignment support since g++4.8, https://gcc.gnu.org/projects/cxx0x.html (N2341)

在code下铛++没有任何问题汇总。

The code compiles under clang++ without any problems.

这是G ++,我不知道的一个众所周知的问题?在线编译器,我测试过(ideone和coliru)拒绝code也。

Is this a well known issue of g++ that I am not aware of? The online compilers that I tested (ideone and coliru) reject the code also.

推荐答案

是的,这是一个已知的缺失功能的GCC:

Yes, this is a known missing feature for gcc :

这篇关于的std :: ALIGN不支持的G ++ 4.9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆