RE: [GD-General] Minor rant - cross-platform configuration
Brought to you by:
vexxed72
From: Brian H. <bri...@py...> - 2002-11-06 19:58:06
|
> Night depression), but I thought Brian was offering to > end the "reinventing the wheel" pattern by posting a > definitive header file that should satisfy the needs > of most cross-platform developers. That's exactly what i'm saying. It's obvious that this problem has been solved before. In lots and lots of different ways. In fact, if you look at any popular open source library, you'll see a "configurator" file that basically does environment inference. SDL, Lua, Apache, MySql, zlib, libpng, ijg, Python, Mesa, Qt, wxWindows, etc. The list goes on, and each of them re-invent the wheel. And for many of the GPL/LGPL ones, if you take their wheel, you've "infected" your own source base in the process. And, of course, a lot of those wheels are overkill (support for PDP-11); incompatible (need C++); encumbered (GPL/LGPL); difficult to use (require manual definition of key constants); difficult to integrate (don't use prefixes and thus pollute the namespace); etc. They all work well for their intended purposes, but excising just the configuration elements can be time consuming and painful. > The reason these > devlopers "rolled their own" header files was because, > I suppose, a standard header file had never been > created or published. Exactly. The mere fact that something as obvious as a comprehensive central repository for compiler defined constants on various architectures doesn't exist is pretty damning. Thankfully someone is at least making an effort: http://predef.sourceforge.net/ I have no idea how anyone finds the above, because it didn't turn up on any of my searches until about an hour into this last night, several pages back. In fact, I still have trouble having it show up in a search engine when entering words straight off the page. It also lacks comments on where/how/when things are defined -- the constants are both compiler and target platform dependent. So _WIN32 might be defined on MSVC, but it's __WIN32__ on Borland. But at least someone has recognized the value of having this documented. > and algorithms, perhaps GOSH will save developers from having > to enter the world of arcane compiler variables and > directives. Sure, there will be people that want custom > headers, just as some people need to avoid STL. That's my intention. And it will be totally unencumbered. It's a frigging header file, header files shouldn't haver licenses =) That said, it's possible that it would expand over time to include other basic functionality that you would expect, the obvious ones being endianess utilities and architecture reporting. There aren't that many different ways to write "Swap16" and "Swap32", yet everyone does it all the time. Sometimes with functions, sometimes with macros, sometimes with shifts/masks, sometimes with unions/swaps, etc. And a generic "Give me a string that tells me what platform this is" would be nice. And, of course, all optional. But that's for another day. Brian |