What is the purpose of a single pound/hash sign (#) on its own line in the C/C++ preprocessor?

后端 未结 3 1748
有刺的猬
有刺的猬 2021-01-31 00:40

I have been looking at the Boost libraries source code, and I have noticed that often there are single pound signs without any preprocessor directives attached to them. I read t

3条回答
  •  日久生厌
    2021-01-31 01:16

    Always check an authoritative source instead of relying on other resources. C is standardised as ISO 9899::2011, C++ also has an ISO standard. Both are well accepted and the final drafts available by a short search. The C standard states in 6.10.7 (C++ has much the same text):

    A preprocessing directive of the form

    # new-line
    

    has no effect.

    This is a null directive, as much as an ; without a preceeding expression in the core-language is a null statement .

    For the preprocessor it is just for formatting/readability to highlight that the lines belong semantically together. (the semicolon OTOH is semantically relevant).

提交回复
热议问题