[Scummvm-devel] Header files.

Max Horn max at quendi.de
Sun Dec 21 09:26:01 CET 2003


Am Sonntag, 21.12.03 um 17:49 Uhr schrieb Marcus Comstedt:

>
> Hi all.
>
> I've become increasinly annoyed with the current situation concerning
> header files in ScummVM.  Right now, <scummsys.h> always gets included
> one way or another.  However, because of the the trickery involved
> with free_check, the system headers defining the prototype for the
> real free() must be included _first_.

Hm. You mean there are systems which don't declare free() in stdlib.h 
(which is always included by scummsys.h) ?

>   This is handled by <stdafx.h>,
> which is included directly by the individual C++ files.  Both
> <scummsys.h> and <stdafx.h> contain a lot of #ifdefs on the OS, and
> <stdafx.h> additionally includes <portdefs.h>, iff NONSTANDARD_PORT is
> defined.
>
> Isn't this a bit messy and over-complicated?

Actually, it is. Personally I'd still remove stdafx.h, and then let the 
build system of each affected port take care of including any special 
"prefix" header file. All compilers/IDEs/build systems I personally 
ever used (e.g. GCC, Metrowerks), allow to specify an include file 
which is automatically prefixed to anything built by the compiler. 
However, sadly enough I am told that some compilers (MSVC6 ?) can't do 
this. Otherwise that would be the perfect solution, IMO.

>  Can't we do this instead:
>
> * <scummsys.h> always includes <portdefs.h> (after config.h, probably)
>
> * The backends which don't have a portdefs.h get one (initially empty)
>
> * Everything from <stdafx.h> goes into the respective <portdefs.h>.
>   Nothing includes <stdafx.h> anymore.
>
> * <stdafx.h> goes away.  => NONSTANDARD_PORT goes away.
>
I'd love to get rid of stdafx.h, one way or the other, so much is clear 
:-)


> * OS-dependent #ifdefs from <scummsys.h> also goes into <portdefs.h>.
>   Stuff that are not tied to a particular port, such as big/little
>   endian and alignment/nonalignment #ifdefs, stay.
>
> * Should common elements be found in multiple <portdefs.h> files, they
>   can be considered for moving into <scummsys.h>.

Overall, I like the proposal, at least if we can't have a global prefix 
file on all targets...


> ?  The x11, sdl and null backends should probably share <portdefs.h>,
> but that seems simple enought to fix.

In fact, that is nothing to worry about at all... They simply would 
have separate portdefs.h files, no problem there. Not that the X11 (nor 
the null) backend seems to be maintained by anybody currently...



Cheers,

Max





More information about the Scummvm-devel mailing list