关于C ++预处理器的一些问题: [英] Few questions about the C++ preprocessor:

查看:118
本文介绍了关于C ++预处理器的一些问题:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于C ++预处理器的一些问题:


  1. 如何使预处理器进入预处理代码的新行?

  2. 如何使预处理器在预处理代码中插入一个制表符或多个空格?



  3. 如何使预处理器将注释插入预处理代码? / div>

    1)使用反斜杠,如Tim指出



    2)我不认为你可以



    3)

      #define COMMENT / ## /这是注释
    #define CPPCOMMENT c)/ ## / c
    #define CCOMMENT(c)/ ## * c * ## /

    COMMENT
    CPPCOMMENT(这是一个c ++注释)
    CCOMMENT(这是ac注释)

    编辑 b
    $ b

    2警告



    1)不能在所有编译器中使用。



    2)不要这样做,它是愚蠢的。


    A few questions about the C++ preprocessor:

    1. how to make the preprocessor go to a new line into the preprocessoring code?
    2. how to make the preprocessor insert a tab character or multiple spaces into the preprocessoring code?
    3. how to make the preprocessor insert comments into the preprocessoring code?

    解决方案

    1) use the backslash, as Tim pointed out

    2) I don't think you can

    3)

    #define COMMENT /##/ this is a comment
    #define CPPCOMMENT(c) /##/ c
    #define CCOMMENT(c) /##* c *##/
    
    COMMENT
    CPPCOMMENT(This is a c++ comment)
    CCOMMENT(This is a c comment)
    

    Edit

    2 Caveats

    1) Doesn't work in all compilers.

    2) Don't do this, it's stupid.

    这篇关于关于C ++预处理器的一些问题:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  4. 查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆