{"action":"opened","issue":{"url":"https://api.github.com/repos/miloyip/json-tutorial/issues/50","repository_url":"https://api.github.com/repos/miloyip/json-tutorial","labels_url":"https://api.github.com/repos/miloyip/json-tutorial/issues/50/labels{/name}","comments_url":"https://api.github.com/repos/miloyip/json-tutorial/issues/50/comments","events_url":"https://api.github.com/repos/miloyip/json-tutorial/issues/50/events","html_url":"https://github.com/miloyip/json-tutorial/issues/50","id":182685609,"number":50,"title":"TUTORIAL02: 用于debug enum的宏","user":{"login":"randawn","id":5003679,"avatar_url":"https://avatars.githubusercontent.com/u/5003679?v=3","gravatar_id":"","url":"https://api.github.com/users/randawn","html_url":"https://github.com/randawn","followers_url":"https://api.github.com/users/randawn/followers","following_url":"https://api.github.com/users/randawn/following{/other_user}","gists_url":"https://api.github.com/users/randawn/gists{/gist_id}","starred_url":"https://api.github.com/users/randawn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/randawn/subscriptions","organizations_url":"https://api.github.com/users/randawn/orgs","repos_url":"https://api.github.com/users/randawn/repos","events_url":"https://api.github.com/users/randawn/events{/privacy}","received_events_url":"https://api.github.com/users/randawn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-13T03:17:46Z","updated_at":"2016-10-13T03:17:46Z","closed_at":null,"body":"@miloyip \r\n您好，\r\n我在test.c里面加了两条用于DEBUG的宏。\r\n> test.c\r\n\r\n```C\r\n#define EXPECT_EQ_RET(expect, actual) EXPECT_EQ_BASE((expect) == (actual), ret_e_name[expect], ret_e_name[actual], \"%s\")\r\n#define EXPECT_EQ_TYPE(expect, actual) EXPECT_EQ_BASE((expect) == (actual), type_e_name[expect], type_e_name[actual], \"%s\")\r\n```\r\n\r\n然后把enum对应的名称数组放在了leptjson.h里面\r\n> leptjson.h\r\n\r\n```C\r\nstatic const char* ret_e_name[] = {  \r\n    \"LEPT_PARSE_OK\",\r\n    \"LEPT_PARSE_EXPECT_VALUE\",\r\n    \"LEPT_PARSE_INVALID_VALUE\",\r\n    \"LEPT_PARSE_ROOT_NOT_SINGULAR\",\r\n    \"LEPT_PARSE_NUMBER_TOO_BIG\"\r\n};\r\nstatic const char* type_e_name[] = {\r\n    \"LEPT_NULL\",\r\n    \"LEPT_FALSE\",\r\n    \"LEPT_TRUE\",\r\n    \"LEPT_NUMBER\",\r\n    \"LEPT_STRING\",\r\n    \"LEPT_ARRAY\",\r\n    \"LEPT_OBJECT\"\r\n};\r\n```\r\n\r\n我有一个疑问：\r\n\r\n1. 如果我加了`static char* ret_e_name[] = ...`，编译器会warn: var defined but not used（虽然现在没用use，但是以后可能会）。\r\n\r\n2. 如果直接写`char* ret_e_name[] = ...`，因为leptjson.h被两个文件同时include，LINK的时候会报错redefine。\r\n\r\n\r\n我在想难道1就是正确的做法吗？通过编译选项把warning去掉？\r\n我总感觉有其他漂亮的办法，希望您能解答。\r\n\r\n"}}
{"actor":{"display_login":"randawn"}}