[edit] Perhaps I should provide some background here.
Macros can be defined with the preprocessor directive #define. The preprocessor does text substitution (search-and-replace) in the initial stage of compilation. So with a source file like
Code:
#define NUMBER 3
int x = NUMBER;
the compiler (after the preprocessor is finished) sees
Macros can be undefined with #undef.
Code:
#undef NUMBER /* nothing here */
Inclosing code in a #if directive causes the code to be removed entirely if the expression is false, or left in place if the expression is true. For
Code:
#if 0
printf("Hello\n");
#endif
the complier would see nothing; whereas with #if 1 or some other true expression the compiler would see the printf() statement.
Macros can be tested for defined-ness with #if defined(MACRO) or #ifdef MACRO, which are functionally equivalent.
The inverse, of course, is #if !defined(MACRO), which is the same as #ifndef MACRO.
You can also use #elif and #else; and an if-elif-else chain must end with a #endif. There's no #endif after each #if, #elif, and #else -- just one at the end.
Code:
#if VERSION > 2
#ifdef DEBUG
whatever
#elif defined(SOMETHING)
something
#endif
#else
#error Version too old
#endif
As you can see, preprocessor directives can be nested.
Anyway, there's a quick introduction to preprocessor directives. There are lots of others, like #error (which generates a compiler error), #line, which changes the line number, etc. Check some documentation for details. [/edit]
Code:
#if !defined(AFX_LIVEVIDEO_H__70943714_3422_4F6A_B79A_ DD84D6EECF17__INCLUDED_)
#define AFX_LIVEVIDEO_H__70943714_3422_4F6A_B79A_DD84D6EEC F17__INCLUDED_
They are called inclusion guards. They're used to prevent a header file from being included multiple times. The first time a header file is included, the macro is not defined, so the header file defines the macro and then the rest of the header file follows. The following times the header is included, the macro is defined, so #if !defined(MACRO) is false, and the header is equivalent to a blank file.
Inclusion guards can prevent many types of errors and are essential for projects with more than a few header files.
The common idiom (which is exactly the same thing) is
Code:
#ifndef HEADER_H
#define HEADER_H
/* ... */
#endif