std::array alignment

前端 未结 4 1551
情歌与酒
情歌与酒 2020-12-11 03:08

Trying out std::tr1::array on a mac i\'m getting 16 byte alignment.

sizeof(int) = 4;  
sizeof( std::tr1::array< int,3 > ) = 16;  
sizeof         


        
4条回答
  •  無奈伤痛
    2020-12-11 03:49

    Since posting, turns I get what I want swapping the IDE setting from the default to..

    LLVM compiler 3.0 Language:
      LLVM C++ standard library:
        =libc++ (LLVM standard library with c++0x support.)
    

    ( CLANG_CXX_LIBRARY = libc++ )l

    Previously the setting was "libstdc++ (gcc c++ standard library)" which appears to have the padding, and that allowed me to include instead of ; and now

    sizeof(array)==sizeof(T)*N
    

    this is all in Xcode 4.2 on mac osx lion. I'm hoping one is simply deprecated and that this behavior is what i'll get on other platforms?

提交回复
热议问题