user20350: I'm putting together a simple sketch to read a few sensors and have come across some odd behaviour associated with #define and #ifdef.
Here are some snippets from my code:
// Defines
//#define DEBUG 1
#define ACCELEROMETER 1
#define GYROSCOPE 1
#define GPSSYSTEM 1
#ifdef GPSSYSTEM
  unsigned int Mth=0;
  unsigned int Day=0;
  char TMZ[2];
#endif

With this snippet the rest of the sketch compiles, but with this:
// Defines
//#define DEBUG 1
#define ACCELEROMETER 1
#define GYROSCOPE 1
//#define GPSSYSTEM 1
#ifdef GPSSYSTEM
  unsigned int Mth=0;
  unsigned int Day=0;
  char TMZ[2];
#endif

The compile fails, claiming that the error is in some functions further down. 
BTW, Mth, Day and TMZ are not used anywhere yet, not are they defined anywhere else.  What is even more odd is that the error messages are announcing the erroneous line numbers to be about 12 lines removed from where they really exist in the sketch, and have no association with the declarations here.
Now, this gives a clean compile:
// Defines
//#define DEBUG 1
#define ACCELEROMETER 1
#define GYROSCOPE 1
#define GPSSYSTEM 1
//#ifdef GPSSYSTEM
  unsigned int Mth=0;
  unsigned int Day=0;
  char TMZ[2];
//#endif

as does this:
// Defines
//#define DEBUG 1
#define ACCELEROMETER 1
#define GYROSCOPE 1
//#define GPSSYSTEM 1
//#ifdef GPSSYSTEM
  unsigned int Mth=0;
  unsigned int Day=0;
  char TMZ[2];
//#endif

I've been chasing this weirdness for a day now and am getting nowhere.

user19513: 
The #ifdef Directive you are using is one of Conditional
  Directive.
  This directive checks whether the identifier is currently defined.

In general, it has following syntax:
#ifdef identifier newline

For Arduino, you can modify your #ifdefs to following code:
#if defined(GPSSYSTEM)
    //Code here
#endif


Explaining your code snippets behaviors:

In your first code snippets, GPSSYSTEM has been defined by following line of code:
#define GPSSYSTEM 1

Now, For this code snippets, #ifdef GPSSYSTEM is true, and following variables are defined.
But, when you comment this #define GPSSYSTEM 1 line in your 2nd code snippets, GPSSYSTEM is no more defined and so #ifdef GPSSYSTEM is false, and thus following variables are not defined which result in compilation errors in your code.
Following same logic, behavior of your 3rd and 4th code snippets can be explained easily.

20350: <p>I'm putting together a simple sketch to read a few sensors and have come across some odd behaviour associated with <code>#define</code> and <code>#ifdef</code>.</p>

<p>Here are some snippets from my code:</p>

<pre><code>// Defines
//#define DEBUG 1
#define ACCELEROMETER 1
#define GYROSCOPE 1
#define GPSSYSTEM 1
#ifdef GPSSYSTEM
  unsigned int Mth=0;
  unsigned int Day=0;
  char TMZ[2];
#endif
</code></pre>

<p>With this snippet the rest of the sketch compiles, but with this:</p>

<pre><code>// Defines
//#define DEBUG 1
#define ACCELEROMETER 1
#define GYROSCOPE 1
//#define GPSSYSTEM 1
#ifdef GPSSYSTEM
  unsigned int Mth=0;
  unsigned int Day=0;
  char TMZ[2];
#endif
</code></pre>

<p>The compile fails, claiming that the error is in some functions further down. </p>

<p>BTW, <code>Mth</code>, <code>Day</code> and <code>TMZ</code> are not used anywhere yet, not are they defined anywhere else.  What is even more odd is that the error messages are announcing the erroneous line numbers to be about 12 lines removed from where they really exist in the sketch, and have no association with the declarations here.
Now, this gives a clean compile:</p>

<pre><code>// Defines
//#define DEBUG 1
#define ACCELEROMETER 1
#define GYROSCOPE 1
#define GPSSYSTEM 1
//#ifdef GPSSYSTEM
  unsigned int Mth=0;
  unsigned int Day=0;
  char TMZ[2];
//#endif
</code></pre>

<p>as does this:</p>

<pre><code>// Defines
//#define DEBUG 1
#define ACCELEROMETER 1
#define GYROSCOPE 1
//#define GPSSYSTEM 1
//#ifdef GPSSYSTEM
  unsigned int Mth=0;
  unsigned int Day=0;
  char TMZ[2];
//#endif
</code></pre>

<p>I've been chasing this weirdness for a day now and am getting nowhere.</p>
 19513: <blockquote>
  <p>The <strong>#ifdef</strong> Directive you are using is one of Conditional
  Directive.
  This directive checks whether the identifier is currently defined.</p>
</blockquote>

<p>In general, it has following syntax:</p>

<pre><code>#ifdef identifier newline
</code></pre>

<p>For Arduino, you can modify your <strong>#ifdef</strong>s to following code:</p>

<pre><code>#if defined(GPSSYSTEM)
    //Code here
#endif
</code></pre>

<blockquote>
  <p>Explaining your code snippets behaviors:</p>
</blockquote>

<p>In your first code snippets, <strong>GPSSYSTEM</strong> has been defined by following line of code:</p>

<pre><code>#define GPSSYSTEM 1
</code></pre>

<p>Now, For this code snippets, <strong>#ifdef GPSSYSTEM</strong> is <strong>true</strong>, and following variables are defined.</p>

<p>But, when you comment this <strong>#define GPSSYSTEM 1</strong> line in your 2nd code snippets, <strong>GPSSYSTEM</strong> is no more defined and so <strong>#ifdef GPSSYSTEM</strong> is <strong>false</strong>, and thus following variables are not defined which result in compilation errors in your code.</p>

<p>Following same logic, behavior of your 3rd and 4th code snippets can be explained easily.</p>
