They are not the same. You can use '#if' with any expression, and you use '#ifdef' with macros.
#if expression
If the value of expression is true, then the code that immediately follows the command will be compiled.
#ifdef macro
If the macro has been defined by a #define statement, then the code immediately following the command will be compiled.
The #ifdef and #ifndef directives are short forms of '#if defined(defined-value)' and '#if !defined(defined-value)' respectively. defined(identifier) is valid in any expression evaluated by the preprocessor, and returns true (in this context, equivalent to 1) if a preprocessor variable by the name identifier was defined with #define and false (in this context, equivalent to 0) otherwise. In fact, the parentheses are optional, and it is also valid to write defined identifier without them.