How to inline a function for only release build.
- by Benjamin
// common.h
// This is foo funtion. It has a body.
__inline void foo() { /* something */ }
// a.cpp
#include "common.h" // for foo function
// Call foo
// b.cpp
#include "common.h" // for foo function
// Call foo
I would like to inline the foo function only when I build for release. -I dont want to inline functions for Debug build.
I tried it but linker errors annoyed me.
In this case, foo function's body is defined in common.h header file.
so if I just do
//common.h
#if !defined(_DEBUG)
__inline
#endif
void foo() { /* something */ }
I will be met a link error in DEBUG build. Because two modules try to include common.h.
I have no idea to solve it.
Is it possible?