I'm making a project, and I get stunned with a problem.
I have 3 libraries.h that includes another special library, definitions.h, but in my Main module, i want to include all the libraries just one time, I mean, I want to test if the library definitions.h
has already been included, and include it or not depending on the result.
Something like
If !(#include"definitions.h")
(#include"definitions.h")
You are looking for include guards.
Example,
#ifndef DEFINITIONS_H
#define DEFINITIONS_H
...
...
#endif
#ifndef DEFINITIONS_H
#define DEFINITIONS_H
//lots of code
//
//
//
//
#endif
There's also non-standard #pragma once
, see Is #pragma once a safe include guard?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With