Reputation: 731
In my project i have a Header file common.h which include many headers in it.Some of the files include Common.h and some other header which are already present in Common .h So In the Pre-Processing stage many functions get prototyped twice(Once from the Included header and other from Gui.h).I was wondering is this would cause any issue in long run.
Please suggest..Thanks in advance..
Upvotes: 0
Views: 86
Reputation: 1152
As Chemistpp suggested,
#pragma once
is a good option to try, though it is non-standard.
Check out the advantages and disadvantages listed in the link.
Upvotes: 0
Reputation: 11546
Headers should have include guards so that they are only processed once:
#ifndef SOME_UNIQUE_STRING
#define SOME_UNIQUE_STRING
// Everything else here
#endif
By "Everything" I mean "everything", starting with your #include
s if any.
SOME_UNIQUE_STRING could be the name of the module as long as it is unlikely to coincide with another define somewhere else.
If you look in your library headers, you will notice they use include guards like this.
Upvotes: 4