Skip to content

#error being incorrectly processed in pre-processor #4617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
thomasonw opened this issue Feb 27, 2016 · 2 comments
Closed

#error being incorrectly processed in pre-processor #4617

thomasonw opened this issue Feb 27, 2016 · 2 comments

Comments

@thomasonw
Copy link

What steps will reproduce the problem?

Using the following test sketch:
`

if defined(AVR_AT90CAN32) || \

defined(__AVR_AT90CAN64__) || \
defined(__AVR_AT90CAN128__)
    #define  CANMB_QUANTITY     15                     

elif defined(AVR_ATmega32C1) || \

  defined(__AVR_ATmega64C1__) || \
  defined(__AVR_ATmega16M1__) || \
  defined(__AVR_ATmega32M1__) || \
  defined(__AVR_ATmega64M1__)
    #define  CANMB_QUANTITY     6                       

else

 #error Unsupported CPU in avr_can.h

endif

void setup() {
Serial.begin(115200);

Serial.println(CANMB_QUANTITY);

}

void loop() {

}

`

What is the expected output? What do you see instead?

While compiling on an ATmega64M1 uC, the line "#error Unsupported CPU in avr_can.h" is reported by the compiler and compiling stops. As there was a match I do not expect to #else lines to be recognized.

What version of the product are you using? On what operating system?

Arduino IDE 1.6.7
Windows 7

Please provide any additional information below.

Additional testing, it seems the #if ... statements are being processed correctly, in that the ATmega64M1 uC was recognized and CANMN_QUANITY was set to 6. But then processing continues on and picked up the #error line.

And it seems it is only the #error that is incorrectly picked up. If I place other directives (e.g., some test #defines) in the #else area, processing seems to work correctly.

@per1234
Copy link
Collaborator

per1234 commented Feb 27, 2016

The issue is caused by arduino/arduino-builder#106. I have submitted a pull request to fix this issue in your ATmegaCAN platform.txt thomasonw/ATmegaxxM1-C1#1.

The MCU specific macros in the example sketch above were converted to bold text by markdown. The correct code is:

#if defined(__AVR_AT90CAN32__) || \
    defined(__AVR_AT90CAN64__) || \
    defined(__AVR_AT90CAN128__)
        #define  CANMB_QUANTITY     15                     

#elif defined(__AVR_ATmega32C1__) || \
      defined(__AVR_ATmega64C1__) || \
      defined(__AVR_ATmega16M1__) || \
      defined(__AVR_ATmega32M1__) || \
      defined(__AVR_ATmega64M1__)
        #define  CANMB_QUANTITY     6                       

#else
         #error Unsupported CPU in avr_can.h
#endif


void setup() {
  Serial.begin(115200);

  Serial.println(CANMB_QUANTITY);

}

void loop() {

}

@thomasonw
Copy link
Author

Thank you, confirmed the pull request solved this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants