[PATCH] autostatic.c

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] autostatic.c

Daniel Richard G.
My next patch is an overhaul of autostatic.c that adds support for older
MSVC versions, fixes the no-init bug in small-static builds, and smooths
out a number of rough edges.

++ autostatic.c

* Move the #includes up to the top, in case PTW32_STATIC_LIB is defined in
   a header file (and a later patch from me will need a symbol from
   implement.h early on)

* Added a big fat comment documenting the pre/post-main() black magic and
   the anchoring business

* The init/exit routines are supposed to return int, not void, and return
   a value of 0 to indicate "no error" (see the "Addendum: int Instead of
   void" section in the Codeguru article)

* I got rid of the attribute_section() macro (in favor of writing things
   out longhand) because it's not enough to abstract away all the
   differences between the various forms of declarations needed (for
   example, #pragma is needed in some cases, and that can't be stuffed into
   a macro (and __pragma() isn't supported by older MSVC versions))

* The way that MSVC pre/post-main() black magic is done changed in 8.0, so
   the code now implements the "old" and "new" ways. I've tested that this
   works for everything back to MSVC6.

* Added a bit at the end to avoid warnings when PTW32_STATIC_LIB is not
   defined in non-inlined builds

++ implement.h

* This bit sticks a reference to autostatic.obj into every object file, so
   that the linker won't optimize it away (for "small static" builds)


--Daniel


--
Daniel Richard G. || [hidden email] || Software Developer
Teragram Linguistic Technologies (a division of SAS)
http://www.teragram.com/

ptw32-autostatic.patch (5K) Download Attachment