zoukankan      html  css  js  c++  java
  • 宏定义:带参数的宏名和为空的宏体

    在wxwidgets中遇到这样的一个宏

    1 /* Macro to cut down on compiler warnings. */
    2 #if 1 /* there should be no more any compilers needing the "#else" version */
    3 #define WXUNUSED(identifier) /* identifier */
    4 #else /* stupid, broken compiler */
    5 #define WXUNUSED(identifier) identifier
    6 #endif

    还有这样的一处应用

    void DoLogString(const wxChar *szString, time_t WXUNUSED(t))

    看的有点懵,网上找了几篇宏定义的规则,举的例子都是带有宏体的,自己试了几个例子才明白这个宏的作用。

    这个宏的作用就是把括号内的参数给屏蔽掉,因为他的宏体为空,也就相当于用空字符来替换他的参数。

    在上面的这个函数体内,是看不到参数t的,也就相当于下面的定义

    void DoLogString(const wxChar *szString, time_t)

    很不起眼的小技巧,却让我着实烦躁了一会儿...

  • 相关阅读:
    LeetCode-434-字符串中的单词数
    LeetCode-415-字符串相加
    字符串
    序列
    元组
    列表
    repr()与str的区别
    输出函数print()
    输入函数input()
    MySQL中快速复制数据表方法汇总
  • 原文地址:https://www.cnblogs.com/mian/p/2406989.html
Copyright © 2011-2022 走看看