Re: [xml] Windows build



Hi,

No, because it introduces another layer between compilers and features.
See
below. And in this concrete case, there are compilers (at least WATCOM),
not using the MS runtime but having the same snprintf issue.

Okay.

Disagree. The included (or replaced) runtime library is part of the
compiler for purposes of claiming standards conformance. What I mean
with compiler is actually a compiler proper + standard library
implementation and each such combination must declare its feature set.

Okay, as long a particular compiler proper + standard library combination
defines a single macro which can be used to distinguish it from other such
combinations. I believe this is mostly the case, so lets go with it.

The __MSCVRT__ switch is an intermediate layer, just as C99 could be, for
simplifying writing the macros:

Compiler Layer:

#ifdef _MSC_VER
#define __MSVCRT__
#define THAT_FEATURE
#endif

 #ifdef __BORLANDC__
 #define __MSVCRT__
 #define THIS_FEATURE
 #endif

 #ifdef _WATCOM
 #define SNPRINTF_NEEDS_UNDERSCORE
 #endif

Intermediate Layer:

#ifdef __MSVCRT__
#define SNPRINTF_NEEDS_UNDERSCORE
#define BUNCH_OF_FEATURES_IMPLIED_BY_MSVCRT
#endif

Feature Layer

#define SNPRINTF_NEEDS_UNDERSCORE
#undef snprintf
#define snprintf _snprintf
#endif

Only question is, wether this will make things really easier.

Well, when I look at it, it won't. Leaving out the feature macros, but
splitting the compiler feature definitions would then perhaps be better,
like

  #ifdef _MSC_VER
  #define snprintf _snprintf
  #define MORE_MSVC_ODDITIES
  #endif

  #ifdef __BORLANDC__
  #define snprintf _snprintf
  #define MORE_BORLAND_ODDITIES
  #endif

  #ifdef _WATCOM
  #define snprintf _snprintf
  #define MORE_WATCOM_ODDITIES
  #endif

This will mention the snprintf issue more than once, true, but is easier to
read than having a macro for each common feature. If a common oddity changes
on one compiler and doesn't on the other, this approach will be easier to
handle and read afterwards.

How about that one?

Ciao
Igor





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]