views:

100

answers:

4

Hi all :) I was reading some code from the Doom 3 SDK ( in a VS solution ) when I found a header like this:

#ifndef __PLAYERICON_H__
#define __PLAYERICON_H__

    class idPlayerIcon {
        public:
            idPlayerIcon();
            ~idPlayerIcon();

        ...... // omitted

        public:
            playerIconType_t iconType;
            renderEntity_t  renderEnt;
            qhandle_t  iconHandle;

        };

#endif  /* !_PLAYERICON_H_ */

The header has no forward class declaration nor #includes so, in my experience it should lead to an error like: Undeclared Identifier or Syntax error, cause renderEntity_t and qhandle_t are not "seen". So how can this compile correctly? Thank you in advance for the answers.

+4  A: 

Because every time it is included, the needed entities are forward declared/included right before it, so everything is defined at the point of inclusion. As you correctly say, it will not work any other way.

rmn
Ugh, this stuff is always great fun to debug.
Ed Swangren
+2  A: 

I guess they include other headers before including this one.

arhuaco
+2  A: 

Since this is a header file it's likely there is an order to their includes elsewhere (where this file is used perhaps?). As long as renderEntity_t and qhandle_t make it into the symbol table prior to this file being included it doesn't matter.

John D.
+1  A: 

Is there something called stdafx.h? Most VS projects have these.

It would simply be a header that includes all the needed files for your application to reduce compile time from including headers.

So it would contain something like this:

#ifndef _STDAFX_H_
#define _STDAFX_H_

#include "playerIconAndOtherVariables.h"
#include "thatFileYouListed.h"

#endif
Daniel
No, there's not..but I'll check for another precompiled header,maybe with another name :) Thank for the input
Salv0