eduardsui / tlse

Single C file TLS 1.2/1.3 implementation, using tomcrypt as crypto library
Other
535 stars 87 forks source link

Fix compilation when `complex.h` is included #73

Closed Wertzui123 closed 1 year ago

Wertzui123 commented 1 year ago

complex.h defines an I macro, which conflicts with libtomcrypt.c.

Thanks for this awesome library, by the way!

Alcaro commented 1 year ago

The #undef I part works, but redefining it like that won't work properly. Before that #undef sequence, I expands to (__extension__ 1.0iF); afterwards, it's just TLS_I_MACRO, which isn't likely to do anything useful.

Instead, consider doing this. https://gcc.gnu.org/onlinedocs/gcc/Push_002fPop-Macro-Pragmas.html

Alternatively, rename it in libtomcrypt.

Wertzui123 commented 1 year ago

Ah, you're right.

Instead, consider doing this. https://gcc.gnu.org/onlinedocs/gcc/Push_002fPop-Macro-Pragmas.html

I think this might cause trouble with some C compilers like TCC (which I'm currently trying to get to work with TLSe).

Alternatively, rename it in libtomcrypt

That worked, but the #undef solution seemed cleaner to me at first sight.

@eduardsui Do you think we should go with #pragma push_macro or editing libtomcrypt.c?

Wertzui123 commented 1 year ago

It looks like TCC supports #pragma push_macro too - I guess I will push that approach now (we can still change it before merging though if anyone might spot a problem).

sjaeckel commented 1 year ago

https://github.com/eduardsui/tlse/issues/68#issuecomment-1206583489

Can you check whether an updated ltc would help? I've fixed those duplicate symbols problems already in the branch mentioned in the comment. But I'm not sure whether the version you bundled is still 100% compatible, so maybe it also breaks somewhere else ...

eduardsui commented 1 year ago

should go with #pragma push_macro or editing libtomcrypt.c?

Hello, and thanks for the fix. I think it's ok, but I would test for the compiler (I'm not sure that #pragma pop/push_macro is standard).

Thanks again, Eduard