为什么我们在 xcode 中的其他 c 标志中保留 -D

发布于 2024-10-08 11:33:37 字数 72 浏览 0 评论 0原文

为什么我们在其他 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

电影里的梦 2024-10-15 11:33:37

-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.

明月夜 2024-10-15 11:33:37

我知道这是一个老问题,您可能已经弄清楚了,但这就是该标志的原因。

正如罗伯特在他的问题中所说,-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 if DEBUG 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文