Dear all,
I’m trying to shift from Arduino IDER to PlatformIO (Visual Studio Code). I have projects with multiple “.ino” files and try to convert them. Unfortunately I’m unable to build the program. I read various posts but couldn’t find a suitable response to my problem.
A simplified version of the current setup has 4 files in /src folder as follows:
/src/main.cpp
#include <Arduino.h>
#include “00_main.h”void setup() {
serial_setup();
fs_setup();
}void loop() {
do_something();
}
00_main.h
#pragma once
#ifndef CONFIG_H
#define CONFIG_H#message “Include configuration file”
#include <Arduino.h>
void serial_setup();
void fs_setup();
#endif
01_serial.cpp
#include <Arduino.h>
#include “00_main.h”void serial_setup() {
Serial.begin(115200);
}
02_fs.cpp
#include <Arduino.h>
#include “00_main.h”/***********************************************************************
Prepare filesystem
***********************************************************************/
void fs_setup() {
if (!FileFS.begin()) {
FileFS.format();
}
My platform.ini looks like this one:
[platformio]>
description = ESP based Influx logger for BYD Combo2
default_envs = ESP32[env]
build_flags =
-D DEBUG_ESP_PORT=Serial
-D NDEBUG
lib_archive = no
lib_ldf_mode = chain
lib_compat_mode = strict
upload_speed = 921600
monitor_speed = 115200
monitor_filters =
esp8266_exception_decoder
default[env:ESP32]
platform = espressif32
board = esp32dev
framework = arduino
board_build.mcu = esp32
board_build.f_cpu = 240000000L
board_build.partitions = huge_app.csv
board_build.filesystem = littlefs
Unfortunatley, the compilation is not possible. After some debugging I figured out that the 00_main.h is included by each .cpp file. The #ifndef at the beginning seems to be ignored.
In file included from src/02_fs.cpp:2:
src/00_main.h:5:4: error: invalid preprocessing directive #message
#message “Include configuration file”
^~~~~~~
In file included from src/01_serial.cpp:2:
src/00_main.h:5:4: error: invalid preprocessing directive #message
#message “Include configuration file”
^~~~~~~
In file included from src/main.cpp:17:
src/00_main.h:5:4: error: invalid preprocessing directive #message
#message “Include configuration file”
Most likely a very stupid mistake but I have no clue how to adress it. Any proposal from the community would be very appreciated.