Expose FILE handler in esp32

RichPiano
Posts: 123
Joined: Mon May 18, 2020 2:51 pm

Expose FILE handler in esp32

Postby RichPiano » Thu Aug 25, 2022 9:40 am

I want to use a client library which does input and output using the FILE* handle. Now it says

Code: Select all

FILE' has no member named 'get
It is not written specifically for xtensa architecture, but it works in AVR. What adaptions would I need to make to make it work on xtensa?

Craige Hales
Posts: 94
Joined: Tue Sep 07, 2021 12:07 pm

Re: Expose FILE handler in esp32

Postby Craige Hales » Thu Aug 25, 2022 1:12 pm

(Been a while since I've thought about this, and I suspect I am misunderstanding, but...)

It sounds like you've called C++ code which expects a C++ stream parameter, from C code using a FILE* argument. You can't make that work by casting a FILE* to a C++ stream; you'll need to write a bit of .cpp file to interface functions between your C code and the CPP code.

There might be a better way to use the library; it might have other API functions that will open the stream and return an opaque stream handle. Opaque means you can't see what the handle really holds because it belongs to the library, not to you.
Craige

Who is online

Users browsing this forum: MicroController and 80 guests