Find programmatically if under C++ or C++/CLI

≯℡__Kan透↙ 提交于 2019-12-05 14:58:48

问题


I would like my C++/CLI headers to compile even when under another platform. Of course I am not expecting to compile them but just ignore them.

Would this be appropriate ? (_MSC_VER)

#ifdef _MSC_VER

    using namespace System;

        namespace ENMFP {

            public ref struct Data {
            };
        }

#endif

Thanks !


回答1:


You can use the __cplusplus_cli predefined macro documented here:

#ifdef __cplusplus_cli

using namespace System;

namespace ENMFP
{
    public ref struct Data
    {
        // ...
    };
}

#endif  // __cplusplus_cli


来源:https://stackoverflow.com/questions/9976194/find-programmatically-if-under-c-or-c-cli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!