#if DEBUG 指令在编译的类库中 [英] #if DEBUG directive in compiled class library

查看:36
本文介绍了#if DEBUG 指令在编译的类库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将在类库中使用 #if DEBUG 指令.编译后的 ClassLibrary.dll 将在单独的 Application.exe 中使用.

I am going to use #if DEBUG directive in a class library. The compiled ClassLibrary.dll will be used in a separate Application.exe.

我的这个类库的调试代码会在以下情况下执行吗?

Will my debug code from this class library be executed in the following situations?

  1. 库在DEBUG模式下编译,应用程序在RELEASE模式下编译
  2. 库在 RELEASE 中编译,应用程序在 DEBUG 中编译

推荐答案

编译器指令在编译时解释,而不是在运行时解释.因此,不管使用的应用程序是在 RELEASE 还是 DEBUG 模式下编译.因此

A compiler directive is interpreted at compile time and not at runtime. Therefore it does not matter, if the using application is compiled in RELEASE or DEBUG mode. Therefore

1.) 库在 DEBUG 模式下编译,应用程序在 RELEASE 模式下编译 =>

1.) library is compiled in DEBUG mode, application is compiled in RELEASE => Yes

2.) 库在 RELEASE 中编译,应用程序在 DEBUG 中编译 =>

2.) library is compiled in RELEASE, application is compiled in DEBUG => No

这篇关于#if DEBUG 指令在编译的类库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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