C++箴言

  1. ポインタ
    1. 初期化不明のあらゆるポインタは、 nullptr であることを前提として遺漏なきよう。
      	(ex.)つねに次の形式を守る。
      	void CMyClass::Routine(CMyObject* pMyObject)
      	{
      		if(pMyObject)
      		{
      			ASSERT_KINDOF(CMyObject, pMyObject); //エラーは、開発時エラー*
      			...;
      		}
      		else
      		{
      			#ifdef DEBUG
      				...; //デバッグ・コーディング
      			#endif
      		}
      	}
      	*CMyObjectクラスでは、[DECLARE_DYNAMIC] 宣言されている必要がある。
      	
    2. 先行ルーチンで初期化(したつもり)であっても、出所不明となりうるポインタは、型不明であることを前提として遺漏なきよう。
      	(ex.)つねに次の形式を守る。
      	void CMyClass::Routine(CObList* pObList)
      	{
      			CMyObject* pMyObject = pObList->GetAt(0);//*
      			if(pMyObject)
      			{
      				ASSERT_KINDOF(CMyObject, pMyObject); //エラーは、開発時エラー
      				...;
      			}
      			else
      			{
      				#ifdef DEBUG
      					...; //デバッグ・コーディング
      				#endif
      			}
      	}
      	*CObList* の検定省略。
      	
  2. その他留意点
    1. インクリメント
      1. 前置インクリメント(++a)と後置インクリメント(a++)
        前置インクリメントでは値の変更は保証されるが、後置インクリメントでは保障されない。
        とくに、ある関数に、その冒頭で値の変更を期待しながら後置インクリメントで値を渡しても――たとえば func(a++) としてもー、当該関数は a の (++前の) 値のまま処理する。
        これが期待外れのときは、前置インクリメントしなければならない。たとえば func(++a)。
        Cf. Postfix Increment and Decrement Operators: ++ and --

mysql箴言

  1. Win10日本語環境でのコマンドプロンプトのコードページ
    1. chcp コマンドでコードページを変える。
      Shift-Jis がデフォルト:(復帰コマンド)chcp 932
      UTF-8 に変更:(変更コマンド) chcp 65001

データ型

MICROSFT C++ 値範囲 参照 コメント
種類 定義 説明        
INT_PTR 符号付きポインターの精度の整数の型 As the pointer precision changes (that is, as it becomes 32 bits when compiled for 32-bit platforms, 64 bits when compiled for 64-bit platforms), these data types reflect the precision accordingly. (32 bits) signed, signed int, int

(64 bits) long long, signed long long
__int32 :: 4 bytes:: -2,147,483,648 to 2,147,483,647

__int64 :: 8 bytes:: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Microsoft, Hardware Dev Censer, The New Data Types.

Docs, Data Type Ranges.
(+同邦訳サイト)
MFC CObList::GetCountなどの戻り値として利用されるので、これを利用するときには、追従必至。
UINT An unsigned INT. An unsigned INT. The range is 0 through 4294967295 decimal.
This type is declared in WinDef.h as follows:
typedef unsigned int UINT
(05/31/2018)

The types __int8, __int16, and __int32 are synonyms for the ANSI types that have the same size, and are useful for writing portable code that behaves identically across multiple platforms. The __int8 data type is synonymous with type char, __int16 is synonymous with type short, and __int32 is synonymous with type int. The __int64 type is synonymous with type long long.(10/09/2018)
unsigned INT

INT: A 32-bit signed integer. The range is -2147483648 through 2147483647 decimal.
This type is declared in WinDef.h as follows:
typedef int INT;
An unsigned INT. The range is 0 through 4294967295 decimal.

__int32 :: 4 bytes:: -2,147,483,648 to 2,147,483,647

__int64 :: 8 bytes:: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Microsoft, Windows Dev Censer, Windows Data Types.

Microsoft, Built-in types, __int8, __int16, __int32, __int64.
メモリを節約する意図で __int8, __int16 を用いても、Windows環境では意味がない。
Visual Studio のコンパイラレベルで __int32 または __int64 に変換されてしまう。