Skip to content

Error with unnamed structs: WARNING: Invalid definition: Expected identifier in nested name. #2683

@inakypg

Description

@inakypg

Hello

The Sphinx parser, using doxygent input, seems to get confused by unnamed structures, used specially in nested unions / structs:

[from the Zephyr kernel in zephyrproject.org include/linux/i2c.h]

   union dev_config {
           uint32_t raw;
       struct {
                   uint32_t        use_10_bit_addr : 1;
           uint32_t        speed : 3;
           uint32_t        is_master_device : 1;
           uint32_t        is_slave_read : 1;
           uint32_t        reserved : 26;
       } bits;
   };

This will likely generate an error such as::

  doc/api/io_interfaces.rst:28: WARNING: Invalid definition: Expected identifier in nested name. [error at 19]
  struct dev_config::@61  dev_config::bits
  -------------------^

The simple workaround is to name that unnamed struct, with an internal name (such as __bits):

   union dev_config {
           uint32_t raw;
       struct __bits {
                   uint32_t        use_10_bit_addr : 1;
           uint32_t        speed : 3;
           uint32_t        is_master_device : 1;
           uint32_t        is_slave_read : 1;
           uint32_t        reserved : 26;
       } bits;
   };

Is this a bug or there is a way to use undocumented unions / structs?

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions