Skip to content

Instantly share code, notes, and snippets.

@uemuraj
Created December 11, 2021 04:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save uemuraj/f5d89a2f726736a026f54ee450930148 to your computer and use it in GitHub Desktop.

_countof() が使えるのは...

#include <stdlib.h>

stdlib.h をインクルードした時なのだけれど、この定義は、

#ifndef _countof
    #define _countof __crt_countof
#endif

なのです。

__crt_countof() は vcruntime.h で定義されますが、 Windows.h をインクルードしていれば、すでにインクルードされています。

自分でマクロやテンプレートは書かないようにしましょう。自戒をこめて。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment