Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


On Sun, Jun 30, 2013 at 2:05 PM, Andrzej J. R. Hunt <andrzej@ahunt.org> wrote:

Finally I've had to do things like replace snprintf with _snprintf --
currently decided using an ifdef -- this seems somewhat unclean but I'm
not sure of any better way to do this.

Usually this is done in a header either by implementing a static
inline wrapper or sometime a simple #define does it.
#ifdef Windows
#define snprintf _snprintf
#endif

The trick is to find the 'right' header to shove that in... or more
cleanly to have a separate 'compat' header and include it at the
judicious place, preferably an existing header that is already
included everywhere in the project...

The _last_ thing you want is to sprinkle
#ifdef Windows
_snprinft(....)
#else
snprintf(....)
#endif

all over the code.
for one this is ugly, for second and more important, very fragile...
any new version of the underlying code taht introduce a new snprintf
would break and require a new patch
whereas with a  header-based solution chance are good that it will
'just work' for future version.

Norbert

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.