title: Understanding #define preprocessor directive macro syntax
body: <p>The following code is taken from the LPC54618.h header file:</p>
  
  <pre><code>typedef struct {
       //...structure elements
       __IO uint32_t SDIOCLKSEL;
       //...more elements
  
  } SYSCON_Type;
  
  #define SYSCON_BASE         (0x40000000u)
  #define SYSCON              ((SYSCON_Type *)SYSCON_BASE)
  </code></pre>
  
  <ol>
  <li><p>As far as I can guess the meaning behind the line </p>
  
  <p><code>#define SYSCON              ((SYSCON_Type *)SYSCON_BASE)</code> </p></li>
  </ol>
  
  <p>I would assume that it creates a pointer named <code>SYSCON</code> that points to a variable of type <code>SYSCON_Type</code> which is stored at the address <code>0x40000000u</code>. Is this really what happens? And is there any ressource that explains the syntax that is being used here (i.e. defining pointers inside macros)?</p>
  
  <ol start="2">
  <li><p>When I try to alter the value of SDIOCLKSEL directly, i.e.: </p>
  
  <p><code>SYSCON-&gt;SDIOCLKSEL = some value;</code></p>
  
  <p>I get an error:</p>
  
  <p><code>error: expected ')'
  error: expected parameter declarator
  error: expected ')'
  error: expected function body after function declarator</code></p></li>
  </ol>
  
  <p>but if I use it inside a function, e.g.:</p>
  
  <pre><code>void foo(void)
  {
     SYSCON-&gt;SDIOCLKSEL = some value;  
  }
  </code></pre>
  
  <p>there is no error. Why is that? Why can't I write directly to the structure?</p>
  
  <p>Any answer would be greatly appreciated!</p>