🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Header-only libraries

Published July 19, 2011
Advertisement
I'm really considering making ANL a header-only library. Seems like it's small enough and specific-purpose enough (ie, not many modules of any given program should need to call into it) that doing so shouldn't hurt anything too drastically, and this way I wouldn't have to try to do binary releases. Thoughts? Yays or nays?
Previous Entry Color Rotation
0 likes 4 comments

Comments

yckx
I like the idea of header only libraries, but I'm not too familiar on what the downsides may be.
July 21, 2011 01:02 AM
JTippetts
I actually ran into a downside. ANL uses gradient look-up tables to generate the Perlin noise. These are static tables, and header-only libraries don't really like static data. Hard to avoid multiple-definition errors if the library is included more than once. I'll probably just stay the course for now, at least until (if) I can eliminate the static tables.
July 21, 2011 01:05 AM
assainator
Is it not possible to create these tables at runtime?
July 21, 2011 01:41 PM
JTippetts
It is, but then I was looking at more refactoring to the base noise generator classes to eliminate them. They're hefty enough that I didn't want them to be members of the generators, otherwise each generator would own their own copy. I could make them static members, but that just puts me right back to where I am now, needing a .cpp for static tables. Generating the tables at run-time still needs there to be a pointer variable, somewhere, that all the various instances can reference, unless I give each generator their own instance. There are a few other things I could have done like wrapping them in functions and taking the chance that the inline operator wouldn't be taken literally, and that the compiler would instead consolidate all the individual instances. In the end, my C++ kung fu isn't strong enough to come up with an elegant solution that doesn't require a huge amount of refactoring. I could spend the time refactoring it, or I could just keep it as-is and spend that time instead on adding more function types and writing more documentation.
July 21, 2011 03:32 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement