FangLin Game Dev Engineer

朝花夕拾

2023-09-07
FangLin
C++

  • #define <宏名>[(<参数表>)] <字符串>
  • 预处理器在程序编译前的预处理过程中进行宏替换
  • 特殊符号
    • #: #define ToString(x) #x
      • 字符串化运算符,一元运算符
      • 操作数必须是宏替换文本中的形参,将实参转换为字符串
      • e.g.
        #define showArgs(...) puts(#__VA_ARGS__)
        showArgs( one\n,       "2\n", three );
        
        puts("one\n, \"2\\n\", three");
        
    • ##: #define Conn(x,y) x##y
      • 记号粘贴运算符,二元运算符
      • 至少一个操作数是宏的形参
      • 会删除运算符前后的空白符
      • e.g.
        #define TEXT_A "Hello, world!"
        #define msg(x) puts( TEXT_ ## x )
        msg(A);
        
    • #@: #define ToChar(x) #@x
  • 优点
    • 方便常量/全局参数修改
    • 提高运行效率
  • 应用
    • 相似子类的代码生成器
    • #ifdef
    • #undef 取消宏定义,以便调用相同名称的函数或者重新定义宏
    • 常用工具函数

没有return的非void函数

  • todo

typedef

  • typedef declarations use the same syntax as ordinary variable declarations. The difference is that instead of declaring “a variable named x of type y”, you declare “a type named x that is a synonym for type y”. The syntax is otherwise the same.

基于行/列式存储的数据库

TCP

  • TCP正常状态转换图
  • 如图,正常情况不会出现SYN和FIN同时置位,标准规定丢弃该类包

Similar Posts

上一篇 调试工具总结

下一篇 垃圾回收机制

Comments