Reputation: 97
I have a header file that has a number of static functions that wrap things.
namespace jhelper {
static void __attribute__((noinline)) writerKey(rapidjson_writer * writer, const char * key)
{ writer->Key(key); }
}
Why? Because writer->Key()
causes a load of asm to be generated. writerKey
is used in templated functions and if writer->Key()
(and similar functions) are not wrapped the size of my executable blows up by several megabytes.
gcc handles this well, but clang likes to spam the following warning:
jsonVisitor.hpp:368:41: warning: 'static' function 'writerKey' declared in header file should be declared 'static inline' [-Wunneeded-internal-declaration]
I very explicitly do not want this inlined. I am not concerned about duplicate copies of static functions existing in separate compilation units as I am using an amalgamated build for releases. How do I suppress this warning? Cheers!
Upvotes: 0
Views: 1319
Reputation: 217135
inline
is now unrelated to inlining (and was mainly just an hint).
As you add attribute to avoid inlining, you should not have inlining.
you might do
static inline void __attribute__((noinline))
writerKey(rapidjson_writer* writer, const char* key)
{
writer->Key(key);
}
Upvotes: 1