0

This thing

#ifndef MONEY_H
#define MONEY_H

#endif

in src/money.h. What is the purpose? I understand the #ifndef macro, but what do we define MONEY_H to? Why? This is taken from the tutorial to the popular Check testing framework. Assuming the autotools setup, not cmake. I've been reading automake, autoconf, and make GNU documentation, and reading that slidedeck everybody recommends, and it cleared many things up about the project structure and layout. But I'm still overwhelemed by the amount of new information and things like these confuse me.

John Bollinger
  • 160,171
  • 8
  • 81
  • 157
  • 1
    Do a search for *header include guard*. – Some programmer dude Jul 24 '18 at 07:16
  • What I really wanted was to received a better tutorial. This one is bad. Why on earth do we define an empty identifier MONEY_H? –  Jul 24 '18 at 10:14
  • You *have* searched and read about [*include guards*](https://en.wikipedia.org/wiki/Include_guard), and possibly about [*translation units*](https://en.wikipedia.org/wiki/Translation_unit_(programming)) as well? Then it should be obvious why the macro definition is needed (or a [`#pragma once`](https://en.wikipedia.org/wiki/Pragma_once)). – Some programmer dude Jul 24 '18 at 10:17
  • Additionally, this is a standard C idiom. It has nothing in particular to do with check-framework except inasmuch as that may *use* the idiom. It is furthermore not GNU-specific, and has nothing at all to do with the Autotools. (Tags edited.) – John Bollinger Jul 26 '18 at 19:05

1 Answers1

1

This is used to avoid double inclusion of your .h file, so that, if the .h is already included, you doesn't include it again

Killian G.
  • 370
  • 2
  • 15