为什么我们在 xcode 中的其他 c 标志中保留 -D
为什么我们在其他 c 标志中使用 -D 。在目标中右键单击进入在构建中获取信息设置其他c标志为什么我们必须写-D就像-DDEBUG
why we use -D in other c flag . in target right click go in get info in build setting other c flags why we we have to write -D like -DDEBUG
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
-D
是用于设置#define
的gcc 标志。您还可以执行诸如-DTWO=2
之类的操作,其效果与#define TWO 2
相同。-D
is the gcc flag for setting a#define
. You can also do things like-DTWO=2
, which has the same effect as#define TWO 2
.我知道这是一个老问题,您可能已经弄清楚了,但这就是该标志的原因。
正如罗伯特在他的问题中所说,
-D
标志用于#define一个值。它被用作-DDEBUG
的原因是一些开发人员使用单独的头文件作为调试版本,其中包含他们正在处理的应用程序/程序的测试值。他们使用#ifdef DEBUG 语句来查看是否已定义DEBUG 以确定他们是否正在编写调试头声明或宏。Xcode 为您提供了此功能,可以轻松区分哪些值用于调试,哪些值用于实际使用。
此外,如果调试标头中存在不处于调试状态时也需要设置的声明,您还可以使用#ifndef DEBUG 创建要在应用的发布版本中使用的标头值或宏。
I know this is an old question and you may already of figured it out, but here is the reason for the flag.
As robert said in his question, the
-D
flag is used to #define a value. The reason it is being used as-DDEBUG
is some developers use separate header files for debug versions that contain test values for the app/program they are working on. They use#ifdef DEBUG
statement to see ifDEBUG
has been defined to determine if they are writing debug header declarations or macros.Xcode includes this for you as a way to easily seperate what values are for debug and and what values are for actual use.
Also you can use
#ifndef DEBUG
to create header values or macros that you want used in the release version of your apps if there is declarations in the debug headers that also need to be set when not in debug.