Salv0
Salv0

Reputation: 1077

Clarification on a header without #includes

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.

Upvotes: 1

Views: 174

Answers (4)

Daniel
Daniel

Reputation: 75

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

Upvotes: 1

John D.
John D.

Reputation: 324

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.

Upvotes: 2

arhuaco
arhuaco

Reputation: 1755

I guess they include other headers before including this one.

Upvotes: 3

rmn
rmn

Reputation: 2426

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.

Upvotes: 4

Related Questions