Document of c-modernization-kit (util) 1.0.0
Loading...
Searching...
No Matches
compiler.h File Reference

コンパイラ検出および抽象化マクロのヘッダーファイル。 More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define COMPILER_MSVC
 MSVC コンパイラの場合に定義されます。
#define COMPILER_CLANG
 Clang コンパイラの場合に定義されます。
#define COMPILER_GCC
 GCC コンパイラの場合に定義されます。
#define COMPILER_UNKNOWN
 未知のコンパイラの場合に定義されます。
#define COMPILER_NAME   "name"
 コンパイラ名の文字列 ("MSVC", "Clang", "GCC", "Unknown")。
#define COMPILER_VERSION   0
 コンパイラバージョンの数値。
#define FORCE_INLINE
 インライン展開を強制します。コンパイラに応じた属性に展開されます。
#define NO_INLINE
 インライン展開を抑制します。コンパイラに応じた属性に展開されます。

Detailed Description

コンパイラ検出および抽象化マクロのヘッダーファイル。

Author
c-modernization-kit sample team
Date
2026/02/06

コンパイラの種類とバージョンを検出し、統一的なマクロを定義します。
また、コンパイラ固有のインライン制御属性を抽象化します。

コンパイラ検出マクロ

検出されたコンパイラに応じて、以下のマクロを定義します。

コンパイラ 識別マクロ COMPILER_NAME COMPILER_VERSION の形式
MSVC COMPILER_MSVC "MSVC" _MSC_VER の値 (例: 1943)
Clang COMPILER_CLANG "Clang" major * 10000 + minor * 100 + patch
GCC COMPILER_GCC "GCC" major * 10000 + minor * 100 + patch
その他 COMPILER_UNKNOWN "Unknown" 0
Note
Clang は GNUC も定義するため、Clang を GCC より先に判定しています。

インライン制御マクロ

コンパイラごとに異なるインライン強制・抑制の構文を、統一的なマクロで提供します。

マクロ名 MSVC GCC/Clang その他
FORCE_INLINE __forceinline inline attribute((always_inline)) inline
NO_INLINE __declspec(noinline) attribute((noinline)) (空)

使用例

#include "compiler.h"
FORCE_INLINE int fast_add(int a, int b)
{
return a + b;
}
NO_INLINE void debug_dump(const char *msg)
{
fprintf(stderr, "%s\n", msg);
}
コンパイラ検出および抽象化マクロのヘッダーファイル。
#define NO_INLINE
インライン展開を抑制します。コンパイラに応じた属性に展開されます。
Definition compiler.h:85
#define FORCE_INLINE
インライン展開を強制します。コンパイラに応じた属性に展開されます。
Definition compiler.h:84

Definition in file compiler.h.

Macro Definition Documentation

◆ COMPILER_MSVC

#define COMPILER_MSVC

MSVC コンパイラの場合に定義されます。

Definition at line 57 of file compiler.h.

◆ COMPILER_CLANG

#define COMPILER_CLANG

Clang コンパイラの場合に定義されます。

Definition at line 58 of file compiler.h.

◆ COMPILER_GCC

#define COMPILER_GCC

GCC コンパイラの場合に定義されます。

Definition at line 59 of file compiler.h.

◆ COMPILER_UNKNOWN

#define COMPILER_UNKNOWN

未知のコンパイラの場合に定義されます。

Definition at line 60 of file compiler.h.

◆ COMPILER_NAME

#define COMPILER_NAME   "name"

コンパイラ名の文字列 ("MSVC", "Clang", "GCC", "Unknown")。

Definition at line 61 of file compiler.h.

◆ COMPILER_VERSION

#define COMPILER_VERSION   0

コンパイラバージョンの数値。

Definition at line 62 of file compiler.h.

◆ FORCE_INLINE

#define FORCE_INLINE

インライン展開を強制します。コンパイラに応じた属性に展開されます。

Definition at line 84 of file compiler.h.

◆ NO_INLINE

#define NO_INLINE

インライン展開を抑制します。コンパイラに応じた属性に展開されます。

Definition at line 85 of file compiler.h.