Need help for building code with ESP-IDF & CMake & Eclipse
Posted: Thu May 14, 2020 2:51 pm
Hi everyone,
I'm new here - not totally new, I've done project with ESP32 on Arduino IDE but now I'm trying to re-factor everything with ESP-IDF and it requires knowledge in different fields I didn't know (e.g CMake).
Now I have a issue with struct in C. I cannot pass the struct which I have defined in [main.h] and used in [main.c] call from another file in [component/sensor.c].
Please help me!!! Here is the example of my project:
[tree of my project]
[main.h]
[sensor.h]
[sensor.c]
[main.c]
[CMakeList.txt - project folder]
[component.mk - project folder]
[CMakeList.txt - component folder]
[component.mk - component folder]
When I run "build", I always get the error message "unknown type name `ax `".
Btw, I use Eclipse with ESP-IDF on Windows10.
Thanks
I'm new here - not totally new, I've done project with ESP32 on Arduino IDE but now I'm trying to re-factor everything with ESP-IDF and it requires knowledge in different fields I didn't know (e.g CMake).
Now I have a issue with struct in C. I cannot pass the struct which I have defined in [main.h] and used in [main.c] call from another file in [component/sensor.c].
Please help me!!! Here is the example of my project:
[tree of my project]
Code: Select all
project:
- CMakeList.txt
- component.mk
- main:
- main.h
- main.c
- component:
- CMakeList.txt
- component.mk
- sensor.c
- include:
- sensor.h
Code: Select all
typedef struct ax
{
uint8_t a;
uint16_t b;
float x;
}ax;
ax ax_ms[500];
Code: Select all
#include "main.h"
void ex_func(uint8_t x, ax *ax_ms);
Code: Select all
#include "sensor.h"
void ex_func(uint8_t x, ax *ax_ms)
{
doing something;
}
Code: Select all
#include "main.h"
ex_func( x, &ax_ms );
[CMakeList.txt - project folder]
Code: Select all
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(example)
Code: Select all
COMPONENT_ADD_INCLUDEDIRS := components/include
COMPONENT_SRCDIRS := components
Code: Select all
set(COMPONENT_ADD_INCLUDEDIRS include ../main)
set(COMPONENT_SRCS "sensor.c")
register_component()
Code: Select all
COMPONENT_ADD_INCLUDEDIRS := include ../main
Btw, I use Eclipse with ESP-IDF on Windows10.
Thanks