Skip to content
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

unwanted DEBUG macro is defined by default #125

Open
lyusupov opened this issue Jun 19, 2024 · 1 comment
Open

unwanted DEBUG macro is defined by default #125

lyusupov opened this issue Jun 19, 2024 · 1 comment

Comments

@lyusupov
Copy link

lyusupov commented Jun 19, 2024

Build platform

Linux

Core version

current 'main' branch

Target

CH32V30x_EVT

To reproduce

Make an empty sketch like that:

#if defined(DEBUG)
#error DEBUG is defined by default
#endif

void setup() { }
void loop() { }

Then try to build it

$ export BOARD=WCH:ch32v:CH32V30x_EVT
$ arduino-cli compile -v --build-path=/tmp/arduino -b "$BOARD" debug/
FQBN: WCH:ch32v:CH32V30x_EVT
Using board 'CH32V30x_EVT' from platform in folder: /home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4
Using core 'arduino' from platform in folder: /home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4

Detecting libraries used...
/home/codespace/.arduino15/packages/WCH/tools/riscv-none-embed-gcc/8.2.0/bin/riscv-none-embed-g++ -DSYSCLK_FREQ_144MHz_HSI=144000000 -march=rv32imafcxw -mabi=ilp32f -msmall-data-limit=8 -msave-restore -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -c -Os -DNDEBUG -Wunused -Wuninitialized -std=gnu++14 -fno-threadsafe-statics -fno-rtti -fno-exceptions -fno-use-cxa-atexit -I/tmp/debug -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/cores/arduino -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/cores/arduino/avr/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/cores/arduino/ch32/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/cores/arduino/ch32/lib/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/system/CH32V30x/USER/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/system/CH32V30x/SRC/Core/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/system/CH32V30x/SRC/Debug/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/system/CH32V30x/SRC/Startup/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/system/CH32V30x/SRC/Peripheral/inc/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/system/CH32V30x/SRC/Peripheral/src/ -fpermissive -w -x c++ -E -CC -DARDUINO_ARCH_CH32 -DCH32V30x -DARDUINO=10607 -DCH32V30x_C -DVARIANT_H="variant_CH32V307VCT6.h" -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/cores/arduino -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/variants/CH32V30x/CH32V307VCT6 -o /dev/null -c /tmp/arduino/sketch/debug.ino.cpp
Error while detecting libraries included by /tmp/arduino/sketch/debug.ino.cpp
Generating function prototypes...
/home/codespace/.arduino15/packages/WCH/tools/riscv-none-embed-gcc/8.2.0/bin/riscv-none-embed-g++ -DSYSCLK_FREQ_144MHz_HSI=144000000 -march=rv32imafcxw -mabi=ilp32f -msmall-data-limit=8 -msave-restore -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -c -Os -DNDEBUG -Wunused -Wuninitialized -std=gnu++14 -fno-threadsafe-statics -fno-rtti -fno-exceptions -fno-use-cxa-atexit -I/tmp/debug -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/cores/arduino -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/cores/arduino/avr/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/cores/arduino/ch32/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/cores/arduino/ch32/lib/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/system/CH32V30x/USER/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/system/CH32V30x/SRC/Core/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/system/CH32V30x/SRC/Debug/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/system/CH32V30x/SRC/Startup/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/system/CH32V30x/SRC/Peripheral/inc/ -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/system/CH32V30x/SRC/Peripheral/src/ -fpermissive -w -x c++ -E -CC -DARDUINO_ARCH_CH32 -DCH32V30x -DARDUINO=10607 -DCH32V30x_C -DVARIANT_H="variant_CH32V307VCT6.h" -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/cores/arduino -I/home/codespace/.arduino15/packages/WCH/hardware/ch32v/1.0.4/variants/CH32V30x/CH32V307VCT6 -o /tmp/1384001371/sketch_merged.cpp -c /tmp/arduino/sketch/debug.ino.cpp
/tmp/debug/debug.ino:2:2: error: #error DEBUG is defined by default
 #error DEBUG is defined by default
  ^~~~~

Expected behavior

'DEBUG' symbol name is too much generic one. It can easily cause namespace conflict with user application or a third-party library.

/* DEBUG UATR Definition */
#ifndef DEBUG
#define DEBUG DEBUG_UART1
#endif

My suggestion is to use other name ( such as CH32_DEBUG or something similar ) for internal purpose of the Core.

Let's make DEBUG macro to be inactive by default in order to avoid namespace conflicts with other source codes.

A user may set it manually in Arduino IDE or by altering content of

  1. boards.txt
  2. platform.txt
  3. variants folder
@maxgerhardt
Copy link
Contributor

maxgerhardt commented Jun 29, 2024

While I do agree, the system/CH32V30x/SRC/ etc files come from the official WCH SDK. as e.g. posted at https://github.com/openwch/ch32v307/tree/main/EVT/EXAM/SRC. So to change that, you would have to file a change request with WCH, not the Arduino croe.

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