How to use #define to assign pins in Arduino

arduinoc-preprocessormacros

I am trying to use #define to create a constant and define a pin, check this code

#define PIN_MICROPHONE 13;

void loop()
{
    analogRead(PIN_MICROPHONE);
}

But when trying to compile, it says this error:

: In function 'void loop()':
error: expected `)' before ';' token
error: expected primary-expression before ')' token
error: expected `;' before ')' token

How can I use #define macros to define pins?

This code compiles ok

#define PIN_MICROPHONE 13;

void loop()
{
    analogRead(13);
}

I am using Arduino 1.0.5

Best Solution

The issue is your semicolon.

#define does not require a semicolon on the end of it.

#define PIN_MICROPHONE 13
void loop()
{
    analogRead(PIN_MICROPHONE);
}

Typically the #define is a pre-compiled directive. That means before the code is compiled a find and replace is done on the text. So the IDE "saw" the code below.

void loop()
{
    analogRead(13;); //not going to work 
}

PS: I thought #defines were not encouraged in Arduino style guides.