#define statements within a namespace

前端 未结 5 1563
旧巷少年郎
旧巷少年郎 2021-02-01 12:34

If I have a #define statement within a namespace as such:

namespace MyNamespace
{
  #define SOME_VALUE 0xDEADBABE
}

Am I correct in saying that

5条回答
  •  南笙
    南笙 (楼主)
    2021-02-01 12:58

    The preprocessor operates (conceptually at least, and often actually too) before namespaces and other language-level concepts "kick in" -- so yes, it's definitely much better to use language-level constructs such as const values wherever you can!

提交回复
热议问题