[GSOC]Firebird Integration Weekly Update 03

Norbert Thiebaud nthiebaud at gmail.com
Sun Jun 30 22:17:41 PDT 2013


On Sun, Jun 30, 2013 at 2:05 PM, Andrzej J. R. Hunt <andrzej at 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


More information about the LibreOffice mailing list