OpenNuvoton / NUC970_NonOS_BSP

Non-OS BSP for NUC970 Series Microprocessor
22 stars 26 forks source link

LwIP example: option LWIP_DEBUG doesn't work correct. #10

Open Hoksmur opened 2 years ago

Hoksmur commented 2 years ago

Subject. But if you #define LWIP_DEBUG before #ifdef LWIP_DEBUG - warning about redefined. Decision: remove any #include directives from lwipopts.h See on stackoverflow

ychuang3 commented 2 years ago

In this BSP, there is only one sample "SampleCode\LwIP_httpd" using the lwip. It does not report any compiling warnings/errors. Would you describe what you have done?

Hoksmur commented 2 years ago

I had need debuging messages from UDP module, it requests #define LWIP_DEBUG 1 and #define UDP_DEBUG (LWIP_DBG_ON | LWIP_DBG_LEVEL_WARNING) into lwipopts.h And I have not had messages on UART(sysprintf)! But directive #define LWIP_DEBUG 11 before #ifdef LWIP_DEBUG into debug.h sends warning message about redefine. Minimise and manual parsing show me, that bodies debug.h and lwipopts.h swaped. So, in examples for other MCUs (like TI, ST) haven't includes in lwipopts.h I Described it in detail on stackoverflow, you can see it still. With includes any debug option doesn't work, not only UDP. You can try build it and test.

ychuang3 commented 2 years ago

The root cause of "redefined" compile warning is that many macros exist in both lwipopts.h and opts.h, for example NO_SYS. It is caused by debug.h includes the opt.h. Remove "#include opt.h" from debug can fix "redefined" compile warning, and it does not affect debug.h.

Hoksmur commented 1 year ago

Do you remember, that lwipopts.h is user setting file, debug.h and opt.h - both part of library and can be included in few projects at the same time? Look - lwipopts.h options defined as need user, and after that library check option in body opt.h; unspecified options check by #ifndef OPTION in a body opt.h and set to default (if it need). Example: opt.h includes lwipopts.h , where NO_SYS sets by user, and then in body opt.h checks.