macro names must be identifiers

Can someone help? I found this site Arduino Hardware Interrupts Tutorial and can't get the three example programs to work. Must be something simple! I get an error

error: macro names must be identifiers

#define LED 9

^

exit status 1
macro names must be identifiers

Post your code.
Use code tags.

#define LED 9
volatile byte state = LOW;

void setup() {
  pinMode(LED, OUTPUT);
  attachInterrupt(0, toggle, RISING);
}

void loop() { 
  digitalWrite(LED, state); 
}

void toggle() { 
  state = !state; 
}

Except you chopped off the #define.

MadTom544:

#define LED 9

volatile byte state = LOW;

void setup() {
    pinMode(LED, OUTPUT);
    attachInterrupt(0, toggle, RISING);
}

void loop() {
    digitalWrite(LED, state);
}

void toggle() {
    state  =  !state; 
}
void toggle() {
    state  =  !state; 
}

This compiles fine if I remove the duplicate definition of toggle()

I still get an error:
#define LED 9
^
exit status 1
macro names must be identifiers

#define LED 9
volatile byte state = LOW;

void setup() {
  pinMode(LED, OUTPUT);
  attachInterrupt(0, toggle, RISING);
}

void loop() { 
  digitalWrite(LED, state); 
}

void toggle() { 
  state = !state; 
}

Copy and paste it to a new .ino.

Is that your full code? It compiles fine for me on IDE version 1.6.9

That's the first example: http://www.bristolwatch.com/arduino/arduino_irq.htm
I'm using 1.8.2 IDE Uno on Com5

That's the code and I get this error:
sketch_apr17a:2: error: macro names must be identifiers

#define LED 13
^
exit status 1
macro names must be identifiers

try changing LED to LED1 or somthing

Mark

Is there a way to "clean" an Arduino project? It really looks like the IDE is stubbornly holding on to some pre-compiled file or something.

I still get an error!

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\MadTo\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\MadTo\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\MadTo\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10802 -build-path C:\Users\MadTo\AppData\Local\Temp\arduino_build_119315 -warnings=default -build-cache C:\Users\MadTo\AppData\Local\Temp\arduino_cache_81419 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\MadTo\AppData\Local\Temp\arduino_modified_sketch_634909\sketch_apr17a.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\MadTo\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\MadTo\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\MadTo\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10802 -build-path C:\Users\MadTo\AppData\Local\Temp\arduino_build_119315 -warnings=default -build-cache C:\Users\MadTo\AppData\Local\Temp\arduino_cache_81419 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\MadTo\AppData\Local\Temp\arduino_modified_sketch_634909\sketch_apr17a.ino
Using board 'uno' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Build options changed, rebuilding all
Detecting libraries used...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\MadTo\AppData\Local\Temp\arduino_build_119315\sketch\sketch_apr17a.ino.cpp" -o "nul"
Generating function prototypes...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\MadTo\AppData\Local\Temp\arduino_build_119315\sketch\sketch_apr17a.ino.cpp" -o "C:\Users\MadTo\AppData\Local\Temp\arduino_build_119315\preproc\ctags_target_for_gcc_minus_e.cpp"
sketch_apr17a:2: error: macro names must be identifiers

#define LED1 9

^

exit status 1
macro names must be identifiers

From the HTML code of http://www.bristolwatch.com/arduino/arduino_irq.htm:

#define LED 9

You have non-breaking spaces instead of regular spaces in your sketch.

Just copy the sketch from reply #2 and everything will be okay.
The forum software converts certain characters when you post a message.

Mark, that makes sense, but still doesn't work! tried to delete spaces...

OK! Works now! I had to rewrite to whole code. I guess copy and paste didn't work from that site.

Thanks for the help! I learned something new! Any other way around this problem?
color coding helps

#define LED 9
volatile byte state = LOW;
void setup() {
  pinMode(LED, OUTPUT);
  attachInterrupt(0, toggle, RISING);
}
void loop() {
  digitalWrite(LED, state);
}
void toggle() {
  state = !state;
}

"Any other way around this problem?"
Stop being a script kitty.

.

is there any to help me i have the same problem

safikulislam729:
is there any to help me i have the same problem

You have some code you didn't post. It generates some errors you didn't post. The solution seems obvious to me.

Surprised it didn't throw up stray \ ?? (sorry about that non-code) errors during the compile.
Tabs, spaces, quotation marks can all generate loads of stray errors from copy and paste code, as I know.
I've never found a quick way of stripping them out. Notepad ++ has a lot of useful editing tools, but never very successful. Dumping the code into Excel and using the CLEAN() function removes some, but not all non-printing characters. Re-writing the code is the penance.

Be careful with copy and paste as the characters may not be ASCII or precisely what you see. This is particularly troublesome with single and double quotes.