判断系统是否是64位
/* 判断当前为32位还是64位,定义64位宏,如果没有定义为32位 */
#if defined(_WIN64) || defined(__amd64) || defined(__aarch64__)
#define __MASHINE_64BITS__
#endif // _WIN64 == 64
判断文件是否为txt
// Judge whether file is txt,otherwise is binary
#define ISFILE_TXT(filename) string_endwith(filename,".txt")
int string_endwith(const char *str,const char *sub) {
int nstr,nsub,i = 0;
char *p,*ps;
nstr = strlen(str);
nsub = strlen(sub);
if ( nstr < nsub )
return 0;
p = (char *)str + nstr - 1;
ps = (char *)sub + nsub - 1;
while (i < nsub && *p == *ps) {
i++;
p--;
ps--;
};
return i < nsub ? 0 : 1;
}
// 基本思路:从str和sub的最后一个字符开始比较,如果直到sub结束都相同,返回1
编译期间将字符串messagestring输出到标准输出设备
#pragma message( messagestring )
#pragma message( "Compiling " __FILE__ )
#pragma message( "Last modified on " __TIMESTAMP__ )
#pragma message("Remember to write some actual code in this sample app!!")
// __FILE__ 当前正在编译的文件名
// __LINE__ 当前正在编译的行号
// __TIMESTAMP__ 当前正在编译的文件的最后修改时间
定义单体类
#define MAKE_SINGLETON(T) T(){} static T& get_inst(){ static T inst; return inst;}