你怎么知道编程方式,如果一个Flex应用程序在调试模式下运行?你怎么、应用程序、方式、模式下

2023-09-08 13:32:31 作者:怪咖

是否可以写code中,将只在调试版本上运行,或通过调试运行时,Flex应用程序? 有没有的Flex提供了一种真正删除code完全由发布版本,如C风格的#define?

该应用程序不一定在网页中运行。

解决方案

您可以做条件编译这样的:

  CONFIG ::调试{
    //如果CONFIG ::调试解析错误在编译时,这将被删除
}
 

然后把它添加到编译器标志:

  -define + = CONFIG ::调试,真
 
你应该知道的S7 300的编程技巧

有关调试版本,以及

  -define + = CONFIG ::调试,假
 

有关发布版本。 配置调试可以是任何东西,如 MY_AWESOME_NAMESPACE foobar的,也没关系。

在这里阅读更多:使用条件编译

Is it possible to write code in a Flex application that will only be run in a debug build, or when running through the debugger? Does Flex provide a way to actually remove code entirely from release builds, like C-style #defines?

The app is not necessarily running in a web page.

解决方案

You can do conditional compilation like this:

CONFIG::debugging {
    // this will be removed if CONFIG::debugging resolves to false at compile time
}

And then add this to the compiler flags:

-define+=CONFIG::debugging,true

for debug builds, and

-define+=CONFIG::debugging,false

for release builds. CONFIG and debugging can be anything, like MY_AWESOME_NAMESPACE and fooBar, it doesn't matter.

Read more here: Using conditional compilation.