I have some code in a header, which is a library shared between multiple projects. The code is templated, so it cannot be moved to a separate source file. As this project is for a small embedded microcontroller, code size is important. As it happens, in one of the projects, a certain function gets inlined many times over, wasting a lot of code space since in this case speed isn't really important.
I can solve this problem immediately by prefixing the function in question with __attribute__ ((noinline))
in the library. However, this then prevents inlining in all the other projects too.
Question: what's the most elegant way to prevent inlining in one project only? The only thought I have now is with macros that need to be defined before including the file, which is possible but a bit messy.