I have already reviewed LDF documentation Library Dependency Finder (LDF) — PlatformIO v6.1 documentation
and I feel like what I have should work. I did see this post which is similar ( "FS.h: No such file or directory" with ldf_mode deep+ ) but the outcome there was that someone filed a bug report and I’m not sure it went anywhere. The workaround is not appropriate in my situation.
Minimal repro:
platformio.ini:
[env:native]
platform = native
lib_ldf_mode = deep+
build_flags = -D NATIVE
src/main.cpp:
#include <lib1.hpp>
int main()
{
my_struct data;
data.value = 123;
}
lib/lib1/src/lib1.hpp:
#ifndef LIB1_DEFINE
#define LIB1_DEFINE
#ifdef NATIVE
#include <stdint.h>
#endif
#ifdef SOMETHINGUNDEFINED
#include "Arduino.h"
#endif
typedef struct my_struct {
int32_t value;
} my_struct;
#endif
When I add the preprocessor conditional the build fails. Not having this snippet results in success.
#ifdef SOMETHINGUNDEFINED
#include "Arduino.h"
#endif
Similar thing happens if I do something along the lines of
#ifdef NATIVE
#include <stdint.h>
#else
#include "Arduino.h"
#endif
I have tried all the modes of lib_ldf_mode just in case.
Am I doing something wrong here? Are there any workarounds? The use case here is developing some libraries in a project I’m working on and I would like to run unit tests on native platform.