LoginSignup
5
4

More than 5 years have passed since last update.

静的配列の要素数を求めるマクロ

Posted at

って標準(?)でどこかで定義されていないのでしょうかね??
Windowsだとstdlib.hあたりに居た気がするのですが。

マクロ
#define _countof(a) (sizeof(a) / sizeof(a[0]))

↓こういう時に使いたくなりますよ・・・ね?

サンプル
    CGPoint points[] = {
        CGPointMake(1, 1),
        CGPointMake(2, 2),
        CGPointMake(3, 3),
        CGPointMake(4, 4),
        CGPointMake(5, 5),
    };
    CGContextAddLines(c, points, _countof(points));
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4