Created
May 20, 2014 18:06
-
-
Save ryochack/ae7d32fa328ee3084800 to your computer and use it in GitHub Desktop.
externの配列定義を使ったビルド時の配列サイズチェック方法 (MINIX3より)
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
| #define RESOURCE_NUM (8) | |
| #define ARRAY_NUM (8) | |
| struct resource { | |
| int id; | |
| unsigned int addr; | |
| int len; | |
| }; | |
| struct resource rscs[] = { | |
| { 0, 0x10, 4 }, | |
| { 1, 0x14, 2 }, | |
| { 2, 0x16, 2 }, | |
| { 3, 0x18, 4 }, | |
| { 4, 0x20, 1 }, | |
| { 5, 0x21, 1 }, | |
| { 6, 0x22, 2 }, | |
| { 7, 0x24, 4 }, | |
| }; | |
| int array[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; | |
| extern int dummy[(RESOURCE_NUM == sizeof(rscs)/sizeof(rscs[0])) ? 1 : -1]; | |
| extern int dummy[(ARRAY_NUM == sizeof(array)/sizeof(array[0])) ? 1 : -1]; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MINIX3の方をマクロ化。