arduino / arduino-ide

Arduino IDE 2.x
https://www.arduino.cc/en/software
GNU Affero General Public License v3.0
2.07k stars 353 forks source link

#ifndef doesn't always recognize a prior definition #2395

Closed fester225 closed 2 months ago

fester225 commented 2 months ago

Describe the problem

ifndef ssid

define ssid "ABCD"

endif

This definition of ssid is declared inside arduino_secrets.h, which is called from within commonMacros.h. CommonMacros.h is at the top of three pages. The error I'm getting is;

arduino_secrets.h:3:14: error: expected unqualified-id before string constant

define ssid "ABCD"

On the one hand, a simple work-around would be to remove the extra commonMacro entries. On the other hand, if #ifndef doesn't work consistently, there's not much point in using it, or... I could be defining ssid incorrectly, in which case, how do I tell ChatGPT?

To reproduce

Compile any program with two or more pages, each of which has #include at the top.

Expected behavior

I expect the compiler to recognize the macros, and variables, defined inside as already existing for the second and third page. No errors. No comments.

Arduino IDE version

2.3.3-nightly-20240227

Operating system

macOS

Operating system version

14.3.1

Additional context

No response

Issue checklist

per1234 commented 2 months ago

Hi @fester225. Thanks for your interest in this open source project. This issue tracker is only to be used to report bugs or feature requests specific to the project. The error you are experiencing is caused by a bug in your code and so is off topic for this issue tracker. This topic is more appropriate for the Arduino Forum. I'm sure we will be able to help you out over there:

https://forum.arduino.cc/


UPDATE: forum topic here:

https://forum.arduino.cc/t/ifndef-doesnt-always-work/1229269