Skip to main content
GameDev.net gamedev.net
🔒 Locked

Includes

Started by dta1 Aug 2, 2002 at 5:30 AM 1 replies 300+ views
Original Post
dta1
dta1
If I include, say windows.h, in more files than necessary. Will this slow down my program or doesn''t it make any bigger difference?
Erase, rewind and improve
Crispy
Crispy
No. Take a look at the first few lines of Windows.h. It should be something like:

#ifndef _WINDOWS_H_
#define _WINDOWS_H_

and the last line should be a corresponding

#endif,

telling the compiler that this file shouldn''t be compiled if _WINDOWS_H_ is already defined (which is done when the compiler enters the file for the first time).

Note: I don''t have access to windows.h right now, so _WINDOWS_H_ may not be the #define that is actually used.

Crispt

"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
siaspete
siaspete
It won''t slow down your program, but it''ll slow down compilation if it''s in more places than necessary.

A good rule of thumb is to only include things in a .cpp file if something in that file needs them, and only include something in a .h file if something including it won''t compile without it.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.