Since I prefer to declare everything in the .h file instead of .c/.cpp to make the whole program more readable, I am always dealing with duplicated definitions because of wrong insertion of them.
Using #ifndef
macro is the traditional way to do that, but I simply hate adding #endif
at the end of my code.
Now, I found a new way to do that. Adding key word extern
before declaring them and declare them again in the .c/.cpp file can also do the trick. Since the compiles simple replace the .h file at the place where the macro #include
is, using extern can solve all the conflicts.