Fix compatibility with -Wshadow and ObjC++ by darknoon · Pull Request #368 · msgpack/msgpack-c

Hi @darknoon, thank you for sending the PR.

Replacing nil with nil_t could break existing code. We need to consider that. We usually apply that kind of breaking change at major version up.

There are some approaches I just came up with.

#if objcpp // somehow detect objc++
struct nil_t { };
#else
struct nil { };
#endif

It seems that we need to write those macro many times. It's not good.

struct nil_t { }; // replace all nil with nil_t
#if !objcpp // NOT objcpp
typedef nil_t nil;
#endif

I haven't tested yet but I believe that it would work well.

After major version up, nil_t is a default. In addition providing MSGPACK_USE_LEGACY_NIL to support older code.

struct nil_t { }; // replace all nil with nil_t
#if MSGPACK_USE_LEGACY_NIL // not defined by default
typedef nil_t nil;
#endif

@nobu-k, what do you think?

Additionally, we compile with -Wshadow in clang, which doesn't like

with_zone(msgpack::zone& zone) : zone(zone) { }

I agree. I think that this part of the PR should be merged.

What do you think? I'm happy to split into two PRs if that would be better for you.

Splitting the PR is nice :) Could you split it?