ricmoo / QRCode

QR code generation library in C, optimized for low-power devices, such as Arduino.
Other
638 stars 202 forks source link

cpp warning #11

Open Adrianotiger opened 4 years ago

Adrianotiger commented 4 years ago

Hi, just want to say that with my new Arduino IDE I got some warnings about constants.

This code:

uint8_t qrcodeBytes[qrcode_getBufferSize(2)];

should create a new array. But since the qrcode_getBufferSize function is not a constant, I get some warnings.

Moving the 2 functions to the header and declaring them with defines, it works like expected:

#define bb_getGridSizeBytes(_size) ((_size * _size + 7) / 8)
#define qrcode_getBufferSize(_ver) bb_getGridSizeBytes((4 * _ver + 17))