跨平台的宏

判断系统是否是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;}
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值