As regarding the header file you can simlpy write it in any c file then give that header file .h extension.This header file you can you can use in any c file by using the #include<> statement.
In case of #ifdef you have to define a macro first.After defining the macro where ever you are using the #ifdef you have to mention the macro name.Its as simple as that.