lmi
[Top][All Lists]
Advanced

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

[lmi] how to deal with std::strtof() (and other C++0x-only functions)?


From: Vadim Zeitlin
Subject: [lmi] how to deal with std::strtof() (and other C++0x-only functions)?
Date: Sun, 22 Jun 2008 15:36:23 +0200

 Hello,

 std::strtof() is in C99 and hence will be in C++0x but is not in C++98 and
is not defined (by any version of) MSVC standard C++ library, hence the
compilation currently fails in numeric_io_traits.hpp which uses it. As
usual, there are several ways to fix this:

0. Just always use standard std::strtod().

1. Define LMI_COMPILER_PROVIDES_STRTOF in config_xxx.hpp and/or configure
   if the function is indeed available and use strtod() if it isn't.

2. Define LMI_COMPILER_NEEDS_STRTOF if the function is _not_ available and
   define strtof() in terms of strtod() if it's defined.

3. Provide std::strtof() (still defined in terms of strtod(), of course) in
   config_msvc.hpp without caring about the other compilers/environments.

 Which one do you prefer? I guess (0) is not acceptable as otherwise you
wouldn't have changed it from strtod() to strtof() in the first place. I
can do (3) which shouldn't create any problems for you but I think there
can be other compilers/standard libraries with the same problem so it
doesn't seem to be right to do it only for MSVC. (1) and (2) are mostly
equivalent but (1) is a bit more standard (e.g. configure defines HAVE_XXX
if XXX is available by default). The choice between them depends on whether
we expect strtof() to be mostly available or mostly not, I guess.

 Of course, I'm also interested in a general rule which would allow me to
solve the same problem for any other C++ 0x functions if it arises for
them.

 TIA,
VZ





reply via email to

[Prev in Thread] Current Thread [Next in Thread]