PICで使用できるMicrochip社提供のコンパイラには、HI-TECH C,C18,C30,C32等が有ります。
これらのコンパイラで、インライン関数が使用できるかを調べたのでまとめてみました。
HI-TECH C,C18コンパイラ
HI-TECH Cと、C18コンパイラでは、インライン関数はサポートされていません。使用したい場合は、関数マクロで代替する必要があります。
参考:
HI-TECH Software Frequently Asked Questions
C30,C32コンパイラ
C30とC32のコンパイラではインライン関数はサポートされており、使い方は同じです。但し、使用するには、コンパイルオプションで以下の2つを指定する必要があります。
オプティマイザで -O2 か -O3を指定する -finline-functionsオプションを使用する |
実際の関数は以下のように定義します。
static inline int funcname() { ... } |
以下はコンパイラのユーザガイドより、inline functionに関する説明文の引用です。
-O2オプション
-O2 turns on all optional optimizations except for loop unrolling (-funroll-loops), function inlining (-finline-functions), and strict aliasing optimizations (-fstrict-aliasing).
It also turns on force copy of memory operands (-fforce-mem) and Frame Pointer elimination (-fomit-frame-pointer). As compared to -O, this option increases both compilation time and the performance of the generated code
-finline-functions オプション
Integrate all simple functions into their callers. The compiler heuristically decides which functions are simple enough to be worth integrating in this way.
If all calls to a given function are integrated, and the function is declared static, then the function is normally not output as assembler code in its own right
MPLAB_C32_User_Guide_51686a.pdfのLanguage Specificsより
コメントを残す