arduino / arduino/Arduino

Comments at end of concatenation macro cause error

Open
#5,079 5 comments 0 reactions 0 assignees View on GitHub
IDE 1.9.x Beta Type: Bug
Dominant language
Java
Stars
14.6k
Forks
7k
PR merge metrics
No merged PRs in 30d

Description

A concatenation macro having a comment at end of same line causes Arduino IDE to fail - appears to be when it is "pasting" for indexing source code. CPP processes the file fine.

Example code
```arduino
# define RXN 2 /* comment here causes error: pasting ... does not give valid preprocessing token */
# define RXN_BUFHEAD(X) Rx ## X ## _BufHead
# define Rxn_BUFHEAD(X) RXN_BUFHEAD(X)
# define Rxn_BufHead Rxn_BUFHEAD(RXN)

static uint8_t Rxn_BufHead; // User read steps on, then takes from buffer

void setup() {

Rx2_BufHead = 0;
}

void loop() {
}
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the provided sketch in Arduino IDE 1.x, focusing on the concatenation macros and the end-of-line comment, then compare its behavior with CPP, which processes the file successfully. Done means the example no longer produces the invalid preprocessing-token error when the comment remains in place.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.