xgboost/utils/xgboost_utils.h~
2014-02-06 15:50:50 -08:00

59 lines
1.1 KiB
C

#ifndef _XGBOOST_UTILS_H_
#define _XGBOOST_UTILS_H_
#ifdef _MSC_VER
#define fopen64 fopen
#else
// use 64 bit offset, either to include this header in the beginning, or
#ifdef _FILE_OFFSET_BITS
#if _FILE_OFFSET_BITS == 32
#warning "FILE OFFSET BITS defined to be 32 bit"
#endif
#endif
#ifdef __APPLE__
#define off64_t off_t
#define fopen64 fopen
#endif
#define _FILE_OFFSET_BITS 64
extern "C"{
#include <sys/types.h>
};
#include <cstdio>
#endif
#include <cstdio>
#include <cstdlib>
namespace utils{
inline void Error( const char *msg ){
fprintf( stderr, "%s\n",msg );
exit( -1 );
}
inline void Assert( bool exp ){
if( !exp ) error( "assert_error" );
}
inline void Assert( bool exp, const char *msg ){
if( !exp ) error( msg );
}
inline void Warning( const char *msg ){
fprintf( stderr, "warning:%s\n",msg );
}
inline FILE *FopenCheck( const char *fname , const char *flag ){
FILE *fp = fopen64( fname , flag );
if( fp == NULL ){
fprintf( stderr, "can not open file \"%s\"\n",fname );
exit( -1 );
}
return fp;
}
};
#endif