-5

You must create an include file that contains symbols for DEBUG, TRUE, FALSE, NULL. The include file must contain a guard.--> I have no Idea what is this. When I read it I just see chinese. What is an include file and how can I make it contain symbols for debug, true, false null, WHAT are symbols? haha and ya what is a "guard".

Thanks in advance!

user1212697
  • 619
  • 1
  • 6
  • 7
  • 4
    This is something that would be answered in the first chapter of any [introductory book on C](http://stackoverflow.com/questions/562303/the-definitive-c-book-guide-and-list). Or [Wikipedia](http://en.wikipedia.org/wiki/Include_file). – Oliver Charlesworth Jan 16 '13 at 18:27
  • It shouldn't be that hard to find out about include guards. And if you don't understand it after doing so, your question could be more specific. – ConfusedProgrammer Jan 16 '13 at 18:31
  • "WHAT are symbols? haha..." haha indeed. :( – netcoder Jan 16 '13 at 18:32

2 Answers2

5

Just to help you out here: http://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

A guard is a mechanism that's used to avoid re-inclusion of the header files, if the header file is used in multiple source files.

There are various ways to implement a guard, but just an example:

#ifndef MY_HEADER_H
#define MY_HEADER_H

<Content of the header file>

#endif
askmish
  • 6,464
  • 23
  • 42
2

Its very simple. Its a macro that is used to stop multiple inclusion

File: guard.h

#ifndef _GUARD
#define _GUARD
    #define DEBUG
    #define TRUE true
    #define FALSE false
    #define NULL 0
#endif

The first time the compiler see's this it will define _GUARD and the next time it see's it, it will do nothing because #ifndef will be false.

andre
  • 7,018
  • 4
  • 43
  • 75
  • Thanks I guess this is it but what is the role of DEBUG,TRUE,FALSE and NULL in the header file? – user1212697 Jan 16 '13 at 18:39
  • So that anywhere you `#include "guard.h"` you can now use the symbols. – andre Jan 16 '13 at 18:41
  • The preprocessor we replace all your TRUE by true in your code (FALSE by false, NULL by 0). If in your code you have : if(my_function()==NULL) it will be for the compiler : if(my_function()==0). For the #define DEBUG it is useful to define debug part in your code using #ifdef DEBUG. – Joze Jan 16 '13 at 18:46