无法在文件中的第一个标记之后定义/取消定义预处理器符号

huangapple go评论56阅读模式
英文:

Cannot define/undefine preprocessor symbols after the first token in a file

问题

在C#中如何使用 #define?

我在C++中有这段代码:

#define _DSC_CHANNEL_ERRORS_HPP_

#define DSC_ChannelErrors(value)    (DSC_E01_##value)

这部分可能是可变的。我该如何使用它?

所有的代码都在 code

英文:

How can I use #define in C#?

I have this code on C++:

#define _DSC_CHANNEL_ERRORS_HPP_

#define DSC_ChannelErrors(value)    (DSC_E01_##value)

This can be variable. How I can use it?

All code is on code.

答案1

得分: 1

C#不支持像C++那样的预处理符号。
你必须像这样定义它们:

public const int NUM = 1;

如果你想创建一个宏,最好的选项是像这样:

public static readonly Func<T> Macro() {};
英文:

C# does not support preprocessor symbols like C++.
You have to define them like this:

public const int NUM = 1;

If you want to create a macro your best option is something like this:

public static readonly Func<T> Macro() {};

huangapple
  • 本文由 发表于 2023年2月16日 04:05:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75464933.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定