Skip to main content
Visitor II
October 27, 2021
Solved

Has anyone else had issues with DEFINES in LWIP not working right?

  • October 27, 2021
  • 1 reply
  • 993 views

So I have run into this a couple of times. Right now I have one that I cannot find a good fix for.

I set SNTP_GET_SERVERS_FROM_DHCP to 1 in CubeMX and generated the project then compiled. It is correctly set in lwipopts.h but in sntp.h and sntp.c it acts as if it is set to zero!

sntp.c has sntp.h and lwip/opt.h included in it.

sntp.h has sntp_opts.h included in it.

sntp_opts.h has lwip/opt.h included in it.

lwip/opt.h has lwipopts.h included in it.

So there's a bunch of nesting of includes and it seems that lwip/opt.h is duplicated in the path to sntp.c.

This seems like an issue with how lwip is set up or a compiler issue... I'm not an expert on this stuff. Anyone have ideas?

Mike.

    This topic has been closed for replies.
    Best answer by TDK

    Defines are handled by the GNU GCC preprocessor, which is an extremely commonly used software and is unlikely to have glaring bugs in the #define handling.

    Duplicated include files are generally fine as there should be include guards or a #pragma once to prevent it from being included multiple times.

    > in sntp.h and sntp.c it acts as if it is set to zero!

    How did you determine this exactly?

    1 reply

    TDKAnswer
    Super User
    October 28, 2021

    Defines are handled by the GNU GCC preprocessor, which is an extremely commonly used software and is unlikely to have glaring bugs in the #define handling.

    Duplicated include files are generally fine as there should be include guards or a #pragma once to prevent it from being included multiple times.

    > in sntp.h and sntp.c it acts as if it is set to zero!

    How did you determine this exactly?

    MStra.3Author
    Visitor II
    October 28, 2021

    OK, turns out there was another Define I needed to SET that was resetting the one I was chasing...

    Thanks for your reply!

    Mike.