Question: I want to check a header in my source file and if its already defined, I want to undefine it.

Is it possible?

Answer: 
You can't do what you seem to want to do. If you don't want the header included your choices are 

don't include it in the first place

conditionally include it or not via the prepocessor e.g.

```
#ifdef INC_MY_HEADER
#include "myheader.h"
#endif

```

or assuming the header has header guards just define the header guard before the header is included e.g. from the commend line -DMY\_HEADER or similar

If the real problem is that you have different headers defining things with the same name then you probably need to look into [namespaces](http://www.cplusplus.com/doc/tutorial/namespaces/) so you don't get clashes
You could stop the header being included - the simplest way would be to remove or comment out the `#include` directive.

You could also pre-define your guards so that the include is inneffective.

```
foo.h
#ifndef __FOO_H
#define __FOO_H

/* contents of foo.h */

#endif /* __FOO_H */

foo.cpp
#define __FOO_H
#include "foo.h"
/* contents of foo.cpp */

```

Using this strategy you could use the preprocessor to select whether to pre-define the guards, or even have inner guards within you header. 

If you really need only to have part of the file included, it would be better to split the file into two.