what does mean #ifndef #define directive

c, c++, directive, g++

Solution

#ifndef 

means: "if not defined"

#define DEF_ARME 

speaks for itself: here the "empty macro" "DEF_ARME" is defined. We can see this construction very often in header files: your whole header file will be included in these:

#ifndef HEADER_NAME
#define HEADER_NAME

(here the code you want to include only once, as is general the case for headers)

#endif

This way: the first time you include the header file, the macro "HEADER_NAME" isn't defined yet, so it will be defined and the header code will be included. If you include the same header later on, HEADER_NAME will be defined already, so the same code won't be included another time.

NOTE: The preprocessor directive

#ifndef

is a condition and (just like any "if then" construction) needs to be ended, in this case with

#endif

Problem

I am new in c++. When I create a header file Arme.h, I get automatically these instructions ``` #ifndef DEF_ARME #define DEF_ARME ``` What does these mean and is it important?

Original source