Question about Macros

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is there a way to make

((PINC&_BV(PINC2))

into a macro? I tried

#define ((PINC&_BV(PINC2)) Trigger;

, however the compiler gives me c:6:9: error: macro names must be identifiers. I'm not sure exactly what that means as I still have quite a bit to learn about C. Do I need to add another header file to enable the use of macros? I currently have only io,interrupt,inttypes,stbool headers. Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You were close - try:

#define Trigger ((PINC&_BV(PINC2))

- name of macro first
- no semi-colon (be very wary of this - all C programmers have made that mistake at some point!)