Created
May 21, 2015 14:33
-
-
Save MasazI/f52666729dcf7c84869a to your computer and use it in GitHub Desktop.
alignment.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// alignment.cpp | |
// CplusplusPractice | |
// | |
// Created by masai on 2015/05/21. | |
// Copyright (c) 2015年 masai. All rights reserved. | |
// | |
#include <iostream> | |
using namespace std; | |
// 構造体のすべてのメンバを4バイト単位で配置する例 | |
struct S{ | |
alignas(uint32_t) uint8_t a_; | |
alignas(uint32_t) uint16_t b_; | |
alignas(uint32_t) uint32_t c_; | |
}; | |
int main(){ | |
// int型のアライメント要求 | |
cout << alignof(int) << endl; | |
cout << alignof(uint32_t) << endl; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment