Pergunta

I have a code like this:

#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

I do not understand where these codes get written to. Is it in a header file? Because I have these codes in the main() function only but statements in the printf() of this code doesn't get printed which means it is getting printed somewhere else. Also if I try to remove this part from main(),program wont execute.

Foi útil?

Solução

#ifdef is not specific to opengl. It is a pre-processor directive that only compiles the code between #ifdef and #endif when the specified symbol (DEBUG) is defined by the compiler.

The code block you have posted is probably written by someone that only wanted the code to be compiled (and run) for DEBUG builds. (not final release / production).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top