{"action":"created","issue":{"url":"https://api.github.com/repos/tomas-abrahamsson/gpb/issues/146","repository_url":"https://api.github.com/repos/tomas-abrahamsson/gpb","labels_url":"https://api.github.com/repos/tomas-abrahamsson/gpb/issues/146/labels{/name}","comments_url":"https://api.github.com/repos/tomas-abrahamsson/gpb/issues/146/comments","events_url":"https://api.github.com/repos/tomas-abrahamsson/gpb/issues/146/events","html_url":"https://github.com/tomas-abrahamsson/gpb/issues/146","id":352734362,"node_id":"MDU6SXNzdWUzNTI3MzQzNjI=","number":146,"title":"Support c/c++ reserved keywords for field names when using '-nif'","user":{"login":"jabarszcz","id":6282766,"node_id":"MDQ6VXNlcjYyODI3NjY=","avatar_url":"https://avatars3.githubusercontent.com/u/6282766?v=4","gravatar_id":"","url":"https://api.github.com/users/jabarszcz","html_url":"https://github.com/jabarszcz","followers_url":"https://api.github.com/users/jabarszcz/followers","following_url":"https://api.github.com/users/jabarszcz/following{/other_user}","gists_url":"https://api.github.com/users/jabarszcz/gists{/gist_id}","starred_url":"https://api.github.com/users/jabarszcz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jabarszcz/subscriptions","organizations_url":"https://api.github.com/users/jabarszcz/orgs","repos_url":"https://api.github.com/users/jabarszcz/repos","events_url":"https://api.github.com/users/jabarszcz/events{/privacy}","received_events_url":"https://api.github.com/users/jabarszcz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-21T22:28:40Z","updated_at":"2018-08-23T12:25:30Z","closed_at":null,"author_association":"NONE","body":"`protoc` seems to add an underscore suffix to field names when they are c/c++ reserved words :  \r\n```\r\n$ cat > x.proto <<EOF                                                                                                                                                \r\nsyntax=\"proto2\";\r\nmessage a_message {\r\n    optional bool private = 1;\r\n}\r\nEOF\r\n\r\n$ ./gpb/bin/protoc-erl -I. x.proto -nif\r\n$ protoc --cpp_out=$PWD x.proto\r\n$ g++ -fPIC -shared -O3 -o x.nif.so x.nif.cc x.pb.cc $(pkg-config --cflags protobuf) $(pkg-config --libs protobuf) -I /usr/lib/erlang/erts-9.3.3/include/\r\nx.nif.cc: In function ‘int p_msg_a_message(ErlNifEnv*, ERL_NIF_TERM, a_message*)’:\r\nx.nif.cc:86:16: error: ‘class a_message’ has no member named ‘set_private’; did you mean ‘set_private_’?\r\n             m->set_private(1);\r\n                ^~~~~~~~~~~\r\n                set_private_\r\nx.nif.cc:88:16: error: ‘class a_message’ has no member named ‘set_private’; did you mean ‘set_private_’?\r\n             m->set_private(1);\r\n                ^~~~~~~~~~~\r\n                set_private_\r\nx.nif.cc:90:16: error: ‘class a_message’ has no member named ‘set_private’; did you mean ‘set_private_’?\r\n             m->set_private(0);\r\n                ^~~~~~~~~~~\r\n                set_private_\r\nx.nif.cc: In function ‘ERL_NIF_TERM u_msg_a_message(ErlNifEnv*, const a_message*)’:\r\nx.nif.cc:139:13: error: ‘const class a_message’ has no member named ‘has_private’; did you mean ‘has_private_’?\r\n     if (!m->has_private())\r\n             ^~~~~~~~~~~\r\n             has_private_\r\nx.nif.cc:142:16: error: expected unqualified-id before ‘private’\r\n         if (m->private())\r\n                ^~~~~~~\r\nx.nif.cc:142:16: error: expected ‘)’ before ‘private’\r\n         if (m->private())\r\n            ~   ^~~~~~~\r\n                )\r\n```\r\nThe list of keywords for protoc : https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/cpp/cpp_helpers.cc#L75-L88\r\nThe logic for field/enum value names : https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/cpp/cpp_helpers.cc#L294-L309"},"comment":{"url":"https://api.github.com/repos/tomas-abrahamsson/gpb/issues/comments/415396005","html_url":"https://github.com/tomas-abrahamsson/gpb/issues/146#issuecomment-415396005","issue_url":"https://api.github.com/repos/tomas-abrahamsson/gpb/issues/146","id":415396005,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNTM5NjAwNQ==","user":{"login":"tomas-abrahamsson","id":850307,"node_id":"MDQ6VXNlcjg1MDMwNw==","avatar_url":"https://avatars1.githubusercontent.com/u/850307?v=4","gravatar_id":"","url":"https://api.github.com/users/tomas-abrahamsson","html_url":"https://github.com/tomas-abrahamsson","followers_url":"https://api.github.com/users/tomas-abrahamsson/followers","following_url":"https://api.github.com/users/tomas-abrahamsson/following{/other_user}","gists_url":"https://api.github.com/users/tomas-abrahamsson/gists{/gist_id}","starred_url":"https://api.github.com/users/tomas-abrahamsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomas-abrahamsson/subscriptions","organizations_url":"https://api.github.com/users/tomas-abrahamsson/orgs","repos_url":"https://api.github.com/users/tomas-abrahamsson/repos","events_url":"https://api.github.com/users/tomas-abrahamsson/events{/privacy}","received_events_url":"https://api.github.com/users/tomas-abrahamsson/received_events","type":"User","site_admin":false},"created_at":"2018-08-23T12:25:30Z","updated_at":"2018-08-23T12:25:30Z","author_association":"OWNER","body":"Thanks for the links to how it is handled. I've pushed a fix to a branch `c++-keywords` in case you'd like to take a look or test if it solves your issue."}}
{"actor":{"display_login":"tomas-abrahamsson"}}