Skip to content

Can't include a module's header file with REACT_STRUCT and REACT_FIELD in main App.cpp #4631

@namrog84

Description

@namrog84

version: RNW 61-stable

App.cpp:
#include "SomeModule.h"
// ...
//use something/SomeStatic/Global from someModule.h
// etc...

SomeModule.h:

REACT_STRUCT(someStruct)
struct someStruct{
REACT_FIELD(someField)
std::string someField;
}
REACT_MODULE
...
// use someStruct
...etc...

When compiling, it gives errors that someStruct was already defined in app.obj and it gets unhappy.

There are some internal reasons we needed to include SomeModule.h in App.cpp for the time being to work around another issue (sneak in the LaunchActivatedEventArgs from App::OnLaunched).
Note: We aren't instantiating a copy of the module or anything, just needed access to a static function.

Known workaround:
I can create a secondary SomeModuleProxy.h to move a few things of why we needed to include this module header in app.cpp but I feel REACT_STRUCT and REACT_FIELDS should be more resilient to such issues.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions