cancel
Showing results for 
Search instead for 
Did you mean: 

Replacing all C++ codes in touchgfx with C

Krautermann
Senior II

I am wondering if it's possible to replace all the C++ codes in the gui folder, that is, View.cpp, presenter.cpp & model.cpp with C codes instead?

Would this result in a conflict with the other files in the generated folder if I leave them as .cpp? I understand I should never edit files in the generated folder as they are from touchgfx but files in gui folder, the user can edit. Has anyone try to write pure C in these files and resulted in working?

 

The reason why I want to change to C is because my boss told me that with C++ there are some issues in regards to DMA performance and other functionalities. Somewhere down the line when the compiler translate C++ to assembly code, there are some issues that prevent DMA from working reliably. He told me that from time to time DMA would randomly stop working. Moreover, with C++ it's harder to read in the assembly code as there are parent and child structure as opposed to C which is much easier to read.

Ideally we want pure C for our application. If this cannot be achieved with touchgfx, then another alternative is to return to STemWin but I have been told by ST support before to not use STemWin as it is no longer supported or part of SEGGER, which is not possible to get support from.

1 ACCEPTED SOLUTION

Accepted Solutions
MM..1
Chief II

Replacing isnt possible , but you can leave func in c++ relative empty and call inside C func ...

But i mean your DMA dont source trouble in c++. 

If you need clean C then try LVGL

View solution in original post

5 REPLIES 5
Pavel A.
Evangelist III

No you cannot easily convert c++ to c. This is like pushing toothpaste back into the tube. 

Long ago when everything was better, except of silicon and few other things, and I was much younger, I'd quit.  These days ... we have to hold on our jobs.  Then EmWin is an option. Segger does support it - of course, it will cost you. Tell your boss that wants and wishes have price tags.

MM..1
Chief II

Replacing isnt possible , but you can leave func in c++ relative empty and call inside C func ...

But i mean your DMA dont source trouble in c++. 

If you need clean C then try LVGL

Bob S
Principal

> my boss told me that with C++ there are some issues in regards to DMA performance

Your boss is mis-informed.  Maybe there are issues with your project's code and DMA. But in general, whether you use C++ or C should have no effect on DMA performance or operation.

If you are using HAL functions to start the DMA operations, that code is all plain C code and shouldn't have name mangling in the assembly listing.  If you need unmangled data names, you can move your buffers out of any classes and declare them as 'extern "C" { uint8_t buf[}; }', then store a pointer to this buffer inside your class instance.

Panchev68
Senior

Fun topic

Hi Krautermann

You can tell your boss that the C++ code in TouchGFX does not use any memory allocation or exceptions. We use the DMA every day to draw the majority of the graphics. No problems here.

Be more aware how you use your operating system. E.g. don't call any blocking functions in your DMA interrupts.

If you change to C-code, I suggest that you spend some time on defining a good application architecture. For example do not put all the GUI in one .c function. For maintainability.

Best Regards