I'm making a small library which will load and display DIB's. In my .cpp file, I need to include some files (ctype.h and fstream.h) but, how do I know if they're already included? Or does the header file make sure it's not defined twice?
I'm making a small library which will load and display DIB's. In my .cpp file, I need to include some files (ctype.h and fstream.h) but, how do I know if they're already included? Or does the header file make sure it's not defined twice?
Code:#ifndef CTYPE_H #define CTYPE_H { .......your code goes here.. } #endif
this translates to: " if ctype.h is not defined yet in the working program , then define it (write it in).......and finishes the if statement at the end with #endif........
that's all
Good Luck
matheo917
All the standard headers should have multiple inclusion guards. If you're making a pre-compiled library I don't think it would matter anyway, as the files would be part of separate translation units.
No, but you can do that using preprocessor statements like
Code://This prevents const.h to be twice included #ifndef _CONST_H_INCLUDED #include <const.h> #endif
Ahh, so it's just an underscore for the . in the filename? Great. Thanks for the help!