How to embed files in C++?
Posted: Fri Oct 07, 2022 6:57 pm
Hi,
I am using the ESP8266_RTOS_SDK trying to write my first app.
I use the COMPONENT_EMBED_TXTFILES feature in the component.mk to embed some certificate (PEM).
The following code then embeds the certificate and corresponding key:
When I put this code in a .c file, it works flawlessly, however if this is in a .cpp file, i get the following
error during compilation:
For now, I have put the embedding code into a separate .c file but I really would like to have it
in the main app.cpp. I am unfamiliar with using gcc's asm(...) in C++, so I would appreciate
any help here.
Thanks
-Fritz
I am using the ESP8266_RTOS_SDK trying to write my first app.
I use the COMPONENT_EMBED_TXTFILES feature in the component.mk to embed some certificate (PEM).
The following code then embeds the certificate and corresponding key:
Code: Select all
static uint8_t d_client_crt_start[] asm("_binary_client_crt_start");
static uint8_t client_crt_end[] asm("_binary_client_crt_end");
static uint8_t client_key_start[] asm("_binary_client_key_start");
static uint8_t client_key_end[] asm("_binary_client_key_end");
When I put this code in a .c file, it works flawlessly, however if this is in a .cpp file, i get the following
error during compilation:
Code: Select all
app.cpp:45:16: error: storage size of 'client_crt_start' isn't known
static uint8_t client_crt_start[] asm("_binary_client_crt_start");
^~~~~~~~~~~~~~~~
For now, I have put the embedding code into a separate .c file but I really would like to have it
in the main app.cpp. I am unfamiliar with using gcc's asm(...) in C++, so I would appreciate
any help here.
Thanks
-Fritz