#if DEBUG ,条件编译中的 DEBUG这个符号哪里定义来的?

屁屁 2008-06-30 09:39:33
#if DEBUG ,条件编译中的 DEBUG这个符号哪里定义来的?
是不是开发环境中哪里先定义好了的? 要不然我自己随便写一个 #if OKRUN 那也可以了?
从哪里可以找到这个定义?
...全文
492 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhnzzy 2008-07-08
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 gomoku 的回复:]
不然我自己随便写一个 #if OKRUN 那也可以了
yes.


C# code
#define OKRUN // method 1: defined in your source code, must be the first none-empty line

using System;
class Program
{
static void Main()
{
#if OKRUN
int t = 123;
#else
double t = 321.0;
#endif
}
}



mothod 2, as a compilation flag:
csc /t:winexe /define:OKRUN …
[/Quote]
屁屁 2008-07-08
  • 打赏
  • 举报
回复
是不是啊?
屁屁 2008-07-07
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 lpcjj1122 的回复:]
DEBUG...你想定义什么符号都行了...

只要在代码文件最前面加上:

C# code#define OKRUN



当然,你也可以删掉它:

C# code#undef OKRUN



呵呵,仅供参考.
[/Quote]
这些 #define 只能在当前的源代码文件中有效吧? 在c# 中 不能跨 多个 .cs 文件吧?
gomoku 2008-06-30
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 soft_fair 的回复:]
DEBUG 和 TRACE 这两个是不是默认就在的?
Project Properties -> Build -> Conditional Compilation Symbols.
下面我看到 有两个checkbox默认打上勾了
[/Quote]

打上勾 == 定义好了 == defined
屁屁 2008-06-30
  • 打赏
  • 举报
回复
DEBUG 和 TRACE 这两个是不是默认就在的?
Project Properties -> Build -> Conditional Compilation Symbols.
下面我看到 有两个checkbox默认打上勾了
lpcjj1122 2008-06-30
  • 打赏
  • 举报
回复
DEBUG...你想定义什么符号都行了...

只要在代码文件最前面加上:
#define OKRUN


当然,你也可以删掉它:
#undef OKRUN


呵呵,仅供参考.
gomoku 2008-06-30
  • 打赏
  • 举报
回复
不然我自己随便写一个 #if OKRUN 那也可以了
yes.


#define OKRUN // method 1: defined in your source code, must be the first none-empty line

using System;
class Program
{
static void Main()
{
#if OKRUN
int t = 123;
#else
double t = 321.0;
#endif
}
}


mothod 2, as a compilation flag:
csc /t:winexe /define:OKRUN program.cs

method 3, configured in your c-sharp project:
Project Properties -> Build -> Conditional Compilation Symbols.

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧