Skip to content

[native_sim] CONFIG_SHELL_GETOPT=y does not build. #95477

@JaagupAverin

Description

@JaagupAverin

Describe the bug

On native posix platforms, the whole zephyr/lib/posix/ subdirectory is ignored if building natively:

if(NOT CONFIG_NATIVE_LIBC)
add_subdirectory(posix)
endif()

This includes the zephyr/lib/posix/options/getopt subdirectory which implements a non-standard (?) getopt interface, including the structure struct getopt_state, which is referenced when CONFIG_SHELL_GETOPT=y is enabled, generating errors like:

/home/jaagup/projects/forest/zephyr/include/zephyr/shell/shell.h:867:22: error: field has incomplete type 'struct getopt_state'
  867 |         struct getopt_state getopt;
      |                             ^
/home/jaagup/projects/forest/zephyr/include/zephyr/shell/shell.h:867:9: note: forward declaration of 'struct getopt_state'
  867 |         struct getopt_state getopt;
      |

On native posix, the system <getopt.h> is included, which does not define this structure.

I am open to making a PR with some direction of how best work around this conflict.

Regression

  • This is a regression.

Steps to reproduce

No response

Relevant log output

Impact

Annoyance – Minor irritation; no significant impact on usability or functionality.

Environment

No response

Additional Context

No response

Metadata

Metadata

Assignees

Labels

area: native portHost native arch port (native_sim)bugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions