purpose:
通过宏_INLINE_ON来控制函数是否inline, 非inline函数有利于在vtune等profiling工具中分析。
1. macros.h
#ifdef _WIN32
#define _INLINE_ON
#endif
#ifdef _INLINE_ON
#define _INLINE inline
#else // _INLINE_ON
#define _INLINE __attribute__((noinline)) // gcc 's attribute.
#endif
2. test.h
#include "macros.h"
#if defined(_INLINE_ON) || defined(_TEST_CPP) // _defined(_TEST_CPP) 保证只会有一份definition
_INLINE func() {
...
}
_INLINE func2() {
...
}
#endif //if defined(_INLINE_ON) || defined(_TEST_CPP)
3. test.cpp
#define _TEST_CPP
#include "test.h"
3042

被折叠的 条评论
为什么被折叠?



