Skip to content

Build failure with lib-lwip when switching to Memory Pools mode: "token '{' is not valid in preprocessor expressions" #63

@ThestralWarrior

Description

@ThestralWarrior

Description

When switching lib-lwip's memory allocation mode from Heap to Memory Pools via menuconfig, the build for the nginx application in catalog-core fails due to invalid use of GNU statement expressions in preprocessor expressions.

Steps to reproduce

  1. Clone catalog-core and setup according to the instructions
  2. Change into nginx directory and enter menuconfig
make menuconfig
  1. Navigate to
Library Configuration -> lwip -> Memory allocation mode -> Memory pools
  1. Save and exit menuconfig
  2. Build with
make -j $(nproc)
  1. Observe the error

Observed Error

/home/unikraft/nginx/nginx-pan/workdir/unikraft/include/uk/essentials.h:105:10: error: token "{" is not valid in preprocessor expressions
   105 |         ({ \
       |          ^
/home/unikraft/nginx/nginx-pan/workdir/libs/lib-lwip/include/lwipopts.h:293:24: note: in expansion of macro ‘MAX’
   293 | #define PBUF_POOL_SIZE MAX(((TCP_WND + TCP_MSS - 1) / TCP_MSS), 2 * IP_REASS_MAX_PBUFS)
       |                        ^~~
...

Root Cause

The macro MAX(...) from uk/essentials.h is defined as

#define MAX(a, b)                                                              \
	({                                                                     \
		__typeof__(a) __a = (a);                                       \
		__typeof__(b) __b = (b);                                       \
		__a > __b ? __a : __b;                                         \
	})

This is a GNU C Statement Expression which appears to fail when used inside preprocessor directives.

Environment

  • Unikraft version: 0.19.0~9603a4ab
  • Host OS: Ubuntu 24.04
  • Architecture: x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions