cancel
Showing results for 
Search instead for 
Did you mean: 

Using C library with TouchGFX

BGuth.1
Senior

I am trying to implement dynamic QRCode generation. I am using the library https://github.com/ricmoo/QRCode and the QRCode widget from https://support.touchgfx.com/4.16/docs/development/ui-development/touchgfx-engine-features/custom-widgets#example-source-code.

The qrcode generation library is in C and uses variable length arrays. TouchGFX, which uses C++ compiler, does not like this and throughs error.

0693W00000aIHcWQAW.pngHow do I inform TouchGFX tool to treat the library as C files? The C library does have extern C used as below. But it still doesn't help.

#ifdef __cplusplus

extern "C"{

#endif  /* __cplusplus */

For your reference, I am attaching the TouchGFX project here.

4 REPLIES 4
Billy OWEN
ST Employee

Hi @BGuth.1​ 

The forum moderator had marked your post as needing a little more investigation and direct support. An online support case has been created on your behalf, please stand by for just a moment and you will hear from us.

Regards,

Billy

Jnevi.1
Senior

you should tell you compiler that it should compile this file as c code. this has nothing to do with touchgfx directly, it is a compiler/IDE setting. what toolchain are you using?

or

the lib says

The version of a QR code is a number between 1 and 40 (inclusive)

uint8_t alignCount = version / 7 + 2;
.
.
.       
uint8_t alignPosition[alignCount];

so you could calc the size manually. but this i would only do for testing as it is no sustainable way(every update of the lib will break your code)

or you try another lib like https://github.com/nayuki/QR-Code-generator ?

Romain DIELEMAN
ST Employee

Hi,

I have an old example (on TouchGFX 4.16.1, but just look at the code) using a QR code widget and therefore using C as well. Hope this helps :thumbs_up:

/Romain

Here is a modified version for TouchGFX4.21.1