OpenSC / libp11

PKCS#11 wrapper library
GNU Lesser General Public License v2.1
310 stars 189 forks source link

true/false variables compile error #472

Closed dlegaultbbry closed 1 year ago

dlegaultbbry commented 2 years ago

On platforms which have stdbool.h and the true/false as macros, things like below cause issues

p11_attr.c: In function 'pkcs11_addattr_bool': p11_attr.c:126:18: error: expected identifier or '(' before numeric constant static CK_BBOOL true = CK_TRUE; ^~~~ p11_attr.c:127:18: error: expected identifier or '(' before numeric constant static CK_BBOOL false = CK_FALSE; ^~~~~ p11_attr.c:128:37: error: lvalue required as unary '&' operand pkcs11_addattr(tmpl, type, value ? &true : &false, sizeof(CK_BBOOL)); ^ p11_attr.c:128:45: error: lvalue required as unary '&' operand pkcs11_addattr(tmpl, type, value ? &true : &false, sizeof(CK_BBOOL));

Maybe convert these to _false and _true or some other name to avoid name clashes?

Jakuje commented 2 years ago

Using _true/_false is common practice. Do you want to submit a PR with such changes?

dlegaultbbry commented 2 years ago

I can do that. I'll setup everything and send something in the next few days.