anchor.diff:      end ++ platform_ldflags(os:type()).
   
   msg_defs_to_proto(MsgDefs) ->
  -    iolist_to_binary(lists:map(fun msg_def_to_proto/1, MsgDefs)).
  +    iolist_to_binary([maybe_syntaxdef(MsgDefs),
  +                      lists:map(fun msg_def_to_proto/1, MsgDefs)]).
  +
  +maybe_syntaxdef(MsgDefs) ->
  +    case contains_any_maptype_field(MsgDefs) of
  +        true  -> "syntax = \"proto2\";\n";
  +        false -> ""
  +    end.
  +
  +contains_any_maptype_field(MsgDefs) ->
  +    lists:any(fun(Fields) ->
  +                      lists:any(fun(#?gpb_field{type={map,_,_}}) -> true; 
  +                                   (_) -> false
  +                                end,
  +                                Fields)
  +              end,
  +              [Fields || {{msg,_}, Fields} <- MsgDefs]).
   
   msg_def_to_proto({{enum, Name}, EnumValues}) ->
       f("enum ~s {~n~s}~n~n",
  
positive.code:                               occurrence=optional,
                                opts=[]}
                    || {I, Type} <- index_seq(Types1)]}].
  
  index_seq(L) -> lists:zip(lists:seq(1, length(L)), L).
  
  
negative.code:       [{timeout, 100, %% timeout for each test
          [{TestDescr, TestFun}]}
         || {TestDescr, TestFun} <- Tests1]}}.
  
  nif_encode_decode_maps_() ->
      ProtocCanMapfields = check_protoc_can_do_mapfields(),
      {Descr, Tests} =
          if ProtocCanMapfields ->
                  {"Nif with map<_,_> fields",
                   [{"encode decode", fun nif_encode_decode_maps/0}]};
             true ->
                  {"Protoc < 3.0.0, not testing nifs with map<_,_> fields", []}
          end,
      {Descr,
       {timeout, 300,  %% timeout for all tests
        [{timeout, 100, %% timeout for each test
          [{TestDescr, TestFun}]}
         || {TestDescr, TestFun} <- Tests]}}.
  
  nif_compiles() ->
      with_tmpdir(
  