some fix to make it more c++

This commit is contained in:
tqchen
2014-09-01 22:06:10 -07:00
parent 50f1b5d903
commit 42fb7b4d9d
7 changed files with 26 additions and 21 deletions

View File

@@ -91,7 +91,7 @@ struct Random{
// use rand instead of rand_r in windows, for MSVC it is fine since rand is threadsafe
// For cygwin and mingw, this can slows down parallelism, but rand_r is only used in objective-inl.hpp, won't affect speed in general
// todo, replace with another PRNG
#if defined(_MSC_VER)||defined(_WIN32)
#if defined(_MSC_VER)||defined(_WIN32)||defined(XGBOOST_STRICT_CXX98_)
return Uniform();
#else
return static_cast<double>(rand_r(&rseed)) / (static_cast<double>(RAND_MAX) + 1.0);

View File

@@ -15,7 +15,7 @@
#endif
#if !defined(__GNUC__)
#define fopen64 fopen
#define fopen64 std::fopen
#endif
#ifdef _MSC_VER
// NOTE: sprintf_s is not equivalent to snprintf,
@@ -31,7 +31,7 @@
#ifdef __APPLE__
#define off64_t off_t
#define fopen64 fopen
#define fopen64 std::fopen
#endif
extern "C" {
@@ -52,6 +52,7 @@ typedef long int64_t;
namespace xgboost {
/*! \brief namespace for helper utils of the project */
namespace utils {
/*! \brief error message buffer length */
const int kPrintBuffer = 1 << 12;
@@ -86,10 +87,10 @@ void HandlePrint(const char *msg);
#ifdef XGBOOST_STRICT_CXX98_
// these function pointers are to be assigned
extern void (*Printf)(const char *fmt, ...);
extern void (*Assert)(int exp, const char *fmt, ...);
extern void (*Check)(int exp, const char *fmt, ...);
extern void (*Error)(const char *fmt, ...);
extern "C" void (*Printf)(const char *fmt, ...);
extern "C" void (*Assert)(int exp, const char *fmt, ...);
extern "C" void (*Check)(int exp, const char *fmt, ...);
extern "C" void (*Error)(const char *fmt, ...);
#else
/*! \brief printf, print message to the console */
inline void Printf(const char *fmt, ...) {