1

I was looking at the C library "mbedtls-SGX". In the file "config.h", I found the following:

#define MBEDTLS_NET_C
#undef MBEDTLS_NET_C

What is the purpose of this? From my understanding, having #undef right after #define means the macro doesn't do anything.

Foobar
  • 7,458
  • 16
  • 81
  • 161
  • I think it's a bug and the lines should've been swapped. – Petr Skocik Nov 18 '18 at 17:13
  • The way it is it basically only does: if MBEDTLS_NET_C isn't undefined or defined to be empty, issue a compile time redefinition warning and then undefine the macro. I'm not sure if that's useful. – Petr Skocik Nov 18 '18 at 17:14
  • I thought it might be a bug, but this same pattern is repeated in multiple places in the header file. – Foobar Nov 18 '18 at 17:37
  • Do look at the comment before them "Comment if your system does not ..." – Hans Passant Nov 18 '18 at 18:27
  • 2
    I've seen code where developers use this type of construct during development to easily define or un-def a macro. Both the lines stay in the code, when you want one over the other, you just comment out the other. It's possible this was used similarly, but instead of removing it in release, they just left both lines uncommented == macro un-def'd. – iVoid Nov 18 '18 at 19:20

0 Answers0