Skip to main content
andy b
Senior
June 22, 2017
Solved

LwIP UDP Define has no reference

  • June 22, 2017
  • 4 replies
  • 1631 views
Posted on June 22, 2017 at 17:28

Hello fellow Ethernet explorers

I am currently trying to make a UDP connection between a stm32f4 discovery board and a pc.I have already made an example work and I am now trying to replicate the result but with a program made from scratch.When trying to build, the IDE tells me that the define ''MEMP_UDP_PCB'' is unknown.The error appears twice in the udp.c file.I have tried searching other reference in my project and have found none.Does anyone know what value should this be defined to? It's used in  udp_new() and udp_remove() functions more specifically it's used for:

pcb = (struct udp_pcb*)memp_malloc(MEMP_UDP_PCB)

and :

memp_free(

MEMP_UDP_PCB,pcb

) 

Any help is much appreciated.

-Andy

#lwip #ethernet
This topic has been closed for replies.
Best answer by waclawek.jan
Posted on June 22, 2017 at 17:43

The enum symbols individual memory pools are generated by the preprocessor, see [lwip]\src\include\lwip\memp.h

/* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */

typedef enum {

#define LWIP_MEMPOOL(name,num,size,desc)  MEMP_##name,

#include 'lwip/memp_std.h'

  MEMP_MAX

} memp_t;

JW

4 replies

waclawek.jan
waclawek.janBest answer
Super User
June 22, 2017
Posted on June 22, 2017 at 17:43

The enum symbols individual memory pools are generated by the preprocessor, see [lwip]\src\include\lwip\memp.h

/* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */

typedef enum {

#define LWIP_MEMPOOL(name,num,size,desc)  MEMP_##name,

#include 'lwip/memp_std.h'

  MEMP_MAX

} memp_t;

JW

andy b
andy bAuthor
Senior
June 22, 2017
Posted on June 22, 2017 at 18:01

Hi

What weird is that this project has been generated using the Cube MX so why does this have no definition associated to it ? Thanks for your response but I still dont know what I should put as a define value.

-Andy
waclawek.jan
Super User
June 22, 2017
Posted on June 22, 2017 at 18:42

You are not supposed to define MEMP_UDP_PCB explicitly - it's defined as an enum constant by preprocessor 'magic' in the enum I showed you above (and in the header it includes, look it up). It should be enough to have LWIP_UDP defined as 1 (well, nonzero) in lwipopts.h, i.e. the user-defined lwip-options header.

I don't and won't use Cube/MX so I won't/can't comment on that.

I also don't know your toolchain/IDE and I don't know which component of it told you it is missing. If it's an over smart editor which can't find the definition for you to jump to it, it's just an annoyance and you can ignore it. If it's the compiler, then there's something wrong in the order of files inclusion, best to be solved by looking at the preprocessed output of udp.c (again I can't tell you how to do that as it's toolchain-dependent).

JW