ifdef v ifndef
It is worth noting that this is done before compilation.
#ifdef SOMETHING
// DO if SOMETHING has been defined.
#endif
#ifndef SOMETHING
// SKIP if SOMETHING has been defined.
#endif
#ifdef IF DEFINED, DO IT.
#ifndef IF NOT DEFINED, DO IT.
So, in a header file for example, we might see;
#ifndef MY_HEADER
#define MY_HEADER
// If this header has not yet been seen, define it and do it.
// So that the next time a file includes this header, it will be excluded.
#endif
No comments:
Post a Comment
Note: only a member of this blog may post a comment.