How to inline a function for only release build.
Posted
by
Benjamin
on Stack Overflow
See other posts from Stack Overflow
or by Benjamin
Published on 2011-01-07T04:33:36Z
Indexed on
2011/01/07
4:53 UTC
Read the original article
Hit count: 258
// 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?
© Stack Overflow or respective owner