fix(lwip): forward-declare struct dhcp before DHCP extra-option hook (IDFGH-17738)#18668
Open
TeTeHacko wants to merge 1 commit into
Open
Conversation
When CONFIG_LWIP_HOOK_DHCP_EXTRA_OPTION_CUSTOM (or _DEFAULT) is enabled,
lwip_default_hooks.h declares
void lwip_dhcp_on_extra_option(struct dhcp *dhcp, ...);
while `struct dhcp` is only forward-declared further down, inside the
`#ifdef CONFIG_LWIP_IPV4` block. Any translation unit that includes the
header therefore declares `struct dhcp` inside the parameter list, which
GCC reports as:
error: 'struct dhcp' declared inside parameter list will not be
visible outside of this definition or declaration [-Werror]
The lwip component is built with -Werror and this diagnostic has no
individual -W flag to waive, so every project enabling the DHCP
extra-option hook fails to build. Reproduced on ESP-IDF v6.0.1 and
current master (GCC 13.2, xtensa-esp32s3).
Add a `struct dhcp;` forward declaration ahead of the prototype. A
pointer parameter only needs an incomplete type, so this is minimal and
sufficient; the redundant forward decl inside CONFIG_LWIP_IPV4 is left
untouched.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
CONFIG_LWIP_HOOK_DHCP_EXTRA_OPTION_CUSTOM(or..._DEFAULT) isenabled,
components/lwip/port/include/lwip_default_hooks.hdeclares:but
struct dhcpis only forward-declared further down, inside the#ifdef CONFIG_LWIP_IPV4block — after this prototype. Everytranslation unit that includes the header therefore declares
struct dhcpinside the parameter list, which GCC reports as:
The lwip component is built with
-Werror, and this particular GCCdiagnostic has no individual
-Wflag, so it cannot be waived with-Wno-error=.... The result: any project that enables the DHCPextra-option hook fails to build.
Reproduction
master(GCC 13.2, xtensa-esp32s3)CONFIG_LWIP_HOOK_DHCP_EXTRA_OPTION_CUSTOM=ywith an app-providedlwip_dhcp_on_extra_option()implementationFix
Add a
struct dhcp;forward declaration ahead of the prototype. A pointerparameter only needs an incomplete type, so this is minimal and
sufficient. The redundant forward declaration inside
CONFIG_LWIP_IPV4is left untouched to keep the diff to a single added line.