Skip to content

[Bug] Issue with variable named interface #729

@joshnewans

Description

@joshnewans

Describe the bug

We were recently porting some code from Linux to Windows and ran into a difficult issue.

Some of the Windows system headers transitively include objbase.h, which contains the line

#define interface struct

If Zenoh is included after these, compilation may fail due to lines such as the following:

static void drop(void* context) {
auto interface = static_cast<ShmProviderAsyncInterface*>(context);
delete interface;
}
static void result(void* context, struct z_buf_layout_alloc_result_t* result) {
auto interface = static_cast<ShmProviderAsyncInterface*>(context);
interface->on_result(Converters::from(*result));
}

In this case interface is interpreted as struct and the line cannot be parsed correctly.

Our solution was to undefine and redefine interface before and after the inclusion of Zenoh, however a minor change to the name of the variables in these and similar cases would remove the issue for future users and save some difficult troubleshooting.

To reproduce

  1. Be on Windows
  2. Include oojbase.h before zenoh.hxx

System info

  • Platform: Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions