![]() |
Defining file name?
I've noticed this in a couple IFI files, and figured it was just some necessary thing for the IFI code, but now it's in Kevin's code and I'm curious.
Why, at the start of most .h files, do we have something similar to Code:
#ifndef _TRACKING_H |
Re: Defining file name?
This is so that the code is included only once. For example, let's say you have three files: file1.h, file2.h, and file3.c.
file1.h is the following: Code:
// file1.hCode:
// file2.hfinally, file3.c is the following: Code:
// file3.c |
Re: Defining file name?
Since the question was already answered, here's more info.
You can do other fun things with preprocessor stuff like that. Example: What if you wanted your code to do something while you were debugging, and something else in your 'production' or complete competition code? Code:
#define DEBUGSo when you're debugging, you just #define DEBUG. When you want your final code to be faster/smaller, just remove the #define DEBUG line, and all your debug-related things will be removed. |
| All times are GMT -5. The time now is 21:57. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi