Replies: 7 comments 13 replies
-
Hi, I have a similar intrest in including this in a cpp project, any way @jwestes, you can help me out on how you did it? I did not seem to be successfull by only wrapping eve_commands.h in extern c. I'm looking forward to any tips on how to include this in a cpp project |
Beta Was this translation helpful? Give feedback.
-
I am not sure what the actual issue is since I am not using C++. The first way I made my library work with Arduino, which is compiled in C++, was to just rename the .c files, so EVE_commands.c to EVE_commands.cpp. My current solution is to make the C++ callable from C and so I added EVE_cpp_wrapper.cpp. But while using a .c file is fine for me you want/need to do it in C++ and not call TFT_init() but rather TFT.init()? Ok, I just tried something, I added the extern "C" on top of EVE.h: ... #ifdef __cplusplus #pragma once #include "EVE_target.h" And of course the closing bracket on the bottom: #ifdef __cplusplus #endif /* EVE_H */ And EVE.h includes EVE_target.h, EVE_config.h and EVE_commands.h. I can now put functions from EVE_commands.c into the Arduino setup() and loop() If this is it, I will add it after some more testing. |
Beta Was this translation helpful? Give feedback.
-
"But while using a .c file is fine for me you want/need to do it in C++ and not call TFT_init() but rather TFT.init()?" I tried that same change and I get all sorts of "143:6 error: conflicting declaration of C function XXX" errors. The only way I could get it to work is by not wrapping target.h in an extern "C". So the top of my eve.h file looks like this. #ifndef EVE_H #pragma once #include "EVE_target.h" #ifdef __cplusplus #include "EVE_config.h" #ifdef __cplusplus |
Beta Was this translation helpful? Give feedback.
-
Using that file, this is an example of the error messages I'm seeing. I get hundreds of them, so I will just show you the first one. Using previously compiled file: C:\Users\jeste\AppData\Local\Temp\VMBuilds\CompleteSurfSystem.Controller\esp32_esp32\Debug 7-in\Gyroscope.cpp.o This header file works for me though. |
Beta Was this translation helpful? Give feedback.
-
I just started a rebuild to see. It takes about 15 minutes and it is 2am here, so I am going to bed, but I will let you know in the morning what I have found. |
Beta Was this translation helpful? Give feedback.
-
I don't use PlatformIO, so I have not seen this. I'm using Visual Studio with VisualMicro. |
Beta Was this translation helpful? Give feedback.
-
Sorry for the delay. Personally I compile with the latest platformio for arduino-esp32 ( I have gotten it to work by removing all |
Beta Was this translation helpful? Give feedback.
-
I would like to do away with tft.h and tft.c and use a Display class instead. In order to do that, I had to wrap all the definitions in eve_commands.h with an extern "c" statement.
Beta Was this translation helpful? Give feedback.
All reactions