5.25.2011

Inlining, third

Yep, I was right. The only way to "inline on demand" is to create a header file with static inline functions and include it via the file where you use them. Though it's also not correct cause using static functions with inline keyword will also work. The more you put in one file, the more GCC is able to optimize out. I don't know what dimensions this could reach in bigger projects and back-and-forth referenced files here and there but I believe it's as "cruel" for the compiler as instanciating template classes or so. The nature of a single-pass compiler can rarely be overcome with simple measures but can sometimes reveal some interesting simplicities in compiler design. However, I'll stick with the static inline approach for memory and numeric functions. It seems to work nice within it's bounds and I'll later be able to debug easier with all those possiblities to still get the jump stack with non-optimized compilation. Yeah, that's it. I found a way more comftable for creating code than with C++ templates! Plus, I finally realized how useless it is tinker with such in stuff in C++ cause it's in easier to realize in C. Another plus point: I can export every function and make libraries out of them! Good solution, really good solution. In the end there's always an optimizer made to optimize away situations no everyday programmer would recognize without diving deep into platform-specific attributes...

Yes, optimizer, YOU WON. For now...

No comments: