如何使用全局#define让所有文件都知道? [英] how to use global #define to let all file know?

查看:817
本文介绍了如何使用全局#define让所有文件都知道?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



是否可以定义"#define"最上层文件中的语句和其他文件导入此文件进行条件编译?


示例,


#define READ_FUNCTION_SUPPORTED在FunctionSwitch中定义.cs


在语句对中有一个代码块"#if READ_FUNCTION_SUPPORTED ....#end"在UI.cs文件中


和 在语句对中有一个代码块"#if READ_FUNCTION_SUPPORTED ....#end"在Business.cs文件中



谢谢和最好的问候,


E-John


解决方案

>是否可以定义"#define""最上层文件中的语句和该文件是否由其他文件导入以进行条件编译?


您可以通过命令行传递定义,或者在VS IDE中传递C#项目,使用项目的Build,条件编译

符号设置。见这里:
$
https://docs.microsoft.com/en-us/visualstudio/ide/reference/build-page-project-designer-csharp?view=vs-2017


Dave



Dear All,

Is it possible to define the "#define" statement in up-most file and this file is imported by other files to do conditional compiling?

Example,

#define READ_FUNCTION_SUPPORTED is defined in FunctionSwitch.cs

there is a code block inside the statement pair "#if READ_FUNCTION_SUPPORTED ....#end" in UI.cs file

and there is a code block inside the statement pair "#if READ_FUNCTION_SUPPORTED ....#end" in Business.cs file

Thanks and Best regards,

E-John

解决方案

>Is it possible to define the "#define" statement in up-most file and this file is imported by other files to do conditional compiling?

You can pass definitions via the command line, or in the VS IDE for a C# project, use the project's Build, conditional compilation
symbols setting. See here:
https://docs.microsoft.com/en-us/visualstudio/ide/reference/build-page-project-designer-csharp?view=vs-2017

Dave


这篇关于如何使用全局#define让所有文件都知道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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