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: 
Do you mean you want to **ensure that the header file is included once and only once?** The standard solution to this is using an *include guard*.

I.e. surround the contents of your header with

```
#ifndef MY_HEADER // a unique identifier for each header
#define MY_HEADER

...

#endif

```

This is guaranteed to work in all platforms. Some compilers also provide a `#pragma` to achieve the same effect with less hassle, e.g. in Visual C++ you can add

```
#pragma once

```

at the start of your header file.
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.