gpt4 book ai didi

c - #ifdef DEBUG{...} 在 opengl 中是什么意思?

转载 作者:太空宇宙 更新时间:2023-11-04 08:56:10 24 4
gpt4 key购买 nike

我有这样的代码:

#ifdef DEBUG
{
unsigned int i;
GLint names;
GLuint *ptr;
printf("hits = %d\n", hits);
ptr = (GLuint *) selectBuffer;
for (i = 0; i < hits; i++) { // for each hit
int j;
names = *ptr;
printf("number of names for hit = %d\n", *ptr);
ptr++;
printf(" z1 is %g;", (float) *ptr / 0xffffffff);
ptr++;
printf(" z2 is %g\n", (float) *ptr / 0xffffffff);
ptr++;
printf(" the name is ");
for (j = 0; j < names; j++) { // For each name.
printf("%d ", *ptr);
ptr++;
}
printf("\n");

}
}
#endif

我不明白这些代码写到哪里去了。它在头文件中吗?因为我只在 main() 函数中有这些代码,但是此代码的 printf() 中的语句没有被打印出来,这意味着它被打印在其他地方。此外,如果我尝试从 main() 中删除此部分,程序将不会执行。

最佳答案

#ifdef 不特定于 opengl。它是一个预处理器指令,当指定符号(DEBUG)由编译器。

您发布的代码块可能是由只希望为 DEBUG 构建编译(和运行)代码的人编写的。 (不是最终发布/生产)。

关于c - #ifdef DEBUG{...} 在 opengl 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16908062/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com