Skip to content

Commit

Permalink
Exclude cpp equality operators from extern "C"
Browse files Browse the repository at this point in the history
Summary:
`extern "C"` disables name mangling, hence input parameter types does not influence the name. That makes it impossible to have several equality operators with `extern "C"` linkage (for different types).

One such operator is defined in Windows SDK, in `guiddef.h`. It in turn is included in `winnt.h` inside `extern "C" { ... }` block. Trying to compile file which both is dependent both on `winnt.h` and `Yoga.h` results in:
```
Yoga.h(50): error C2733: 'operator ==': second C linkage of overloaded function not allowed
guiddef.h(192): note: see declaration of 'operator =='
```

In general it doesn't make much sense to have cpp specific operator to have `extern "C"` linkage, so the change doesn't introduce any controlling flag (mangling on/off).

Note that it's breaking binary compatibility and yoga library should be rebuilt if those operators are used.

Reviewed By: milend

Differential Revision: D10418395

fbshipit-source-id: 2f1cccff26165e638b9a07eece07d94fccfa5e5a
  • Loading branch information
blackm00n authored and facebook-github-bot committed Oct 18, 2018
1 parent 8427f64 commit d9792b3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ReactCommon/yoga/yoga/Yoga.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ extern const YGValue YGValueAuto;

#ifdef __cplusplus

YG_EXTERN_C_END

extern bool operator==(const YGValue& lhs, const YGValue& rhs);
extern bool operator!=(const YGValue& lhs, const YGValue& rhs);

YG_EXTERN_C_BEGIN

#endif

typedef struct YGConfig* YGConfigRef;
Expand Down

0 comments on commit d9792b3

Please sign in to comment.