{"action":"created","issue":{"url":"https://api.github.com/repos/troydhanson/uthash/issues/150","repository_url":"https://api.github.com/repos/troydhanson/uthash","labels_url":"https://api.github.com/repos/troydhanson/uthash/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/troydhanson/uthash/issues/150/comments","events_url":"https://api.github.com/repos/troydhanson/uthash/issues/150/events","html_url":"https://github.com/troydhanson/uthash/issues/150","id":303334858,"number":150,"title":"[vs2017] \"conditional expression is constant\"; \"unreachable code uthash_bug\"","user":{"login":"silvioprog","id":1456829,"avatar_url":"https://avatars0.githubusercontent.com/u/1456829?v=4","gravatar_id":"","url":"https://api.github.com/users/silvioprog","html_url":"https://github.com/silvioprog","followers_url":"https://api.github.com/users/silvioprog/followers","following_url":"https://api.github.com/users/silvioprog/following{/other_user}","gists_url":"https://api.github.com/users/silvioprog/gists{/gist_id}","starred_url":"https://api.github.com/users/silvioprog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silvioprog/subscriptions","organizations_url":"https://api.github.com/users/silvioprog/orgs","repos_url":"https://api.github.com/users/silvioprog/repos","events_url":"https://api.github.com/users/silvioprog/events{/privacy}","received_events_url":"https://api.github.com/users/silvioprog/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-08T02:36:49Z","updated_at":"2018-03-10T21:56:12Z","closed_at":"2018-03-10T21:56:12Z","author_association":"NONE","body":"Hello dudes.\r\n\r\nI'm trying to compile a small library that uses `uthash.h`, but it raises some errors at build time on Visual Studio 2017 (the project declares the flags `/Wall /WX`).\r\n\r\nThe VS files was easily made by this cmake file:\r\n\r\n`CMakeFile.txt`\r\n```cmake\r\ncmake_minimum_required(VERSION 3.5)\r\nproject(uthash_bug C)\r\n\r\nset(CMAKE_C_STANDARD 99)\r\n\r\nif (MSVC)\r\n    set(CMAKE_C_FLAGS_RELEASE \"${CMAKE_C_FLAGS_RELEASE} /Wall /WX /MT\")\r\n    set(CMAKE_C_FLAGS_DEBUG \"${CMAKE_C_FLAGS_DEBUG} /Wall /WX\")\r\nendif ()\r\n\r\nadd_executable(uthash_bug\r\n               uthash.h\r\n               main.c)\r\nif (MSVC_VERSION GREATER 1800)\r\n    target_compile_definitions(uthash_bug PUBLIC _NO_CRT_STDIO_INLINE)\r\nendif ()\r\n```\r\n\r\nand this command line:\r\n\r\n```bash\r\nmkdir build && cd build/ && cmake -G \"Visual Studio 15 2017\" ..\r\n```\r\n\r\nit generates all the required files for building the project on VS; just open the generated `uthash_bug.sln` and try to build the project in the VS (or, if you are an expert, just call the `CL` command by hand in the console).\r\n\r\nFirst error:\r\n\r\n```cmd\r\nconditional expression is constant\r\n\r\nC:\\CLionProjects\\uthash_bug\\main.c\t23\r\n```\r\nso, after commenting line 23:\r\n\r\n```cmd\r\nunreachable code\r\n\r\nc:\\clionprojects\\uthash_bug\\main.c\t21\r\n```\r\n\r\nthe code used in the example was:\r\n\r\n```c\r\n01. #include <string.h>\r\n02. #include <stdlib.h>\r\n03. #include <stdio.h>\r\n04. #include \"uthash.h\"\r\n05. \r\n06. struct my_struct {\r\n07.     const char *name;\r\n08.     int id;\r\n09.     UT_hash_handle hh;\r\n10. };\r\n11. \r\n12. \r\n13. int main(void) {\r\n14.     const char **n, *names[] = {\"joe\", \"bob\", \"betty\", NULL};\r\n15.     struct my_struct *s, *tmp, *users = NULL;\r\n16.     int i = 0;\r\n17.     for (n = names; *n != NULL; n++) {\r\n18.         s = (struct my_struct *) malloc(sizeof(struct my_struct));\r\n19.         s->name = *n;\r\n20.         s->id = i++;\r\n21.         HASH_ADD_KEYPTR(hh, users, s->name, strlen(s->name), s);\r\n22.     }\r\n23.     HASH_FIND_STR(users, \"betty\", s);\r\n24.     if (s) printf(\"betty's id is %d\\n\", s->id);\r\n25.     HASH_ITER(hh, users, s, tmp) {\r\n26.         HASH_DEL(users, s);\r\n27.         free(s);\r\n28.     }\r\n29.     return 0;\r\n30. }\r\n```\r\nI'm not macro expert, but I've tried to fix this problem anyway, however, any progress. :disappointed: "},"comment":{"url":"https://api.github.com/repos/troydhanson/uthash/issues/comments/372070315","html_url":"https://github.com/troydhanson/uthash/issues/150#issuecomment-372070315","issue_url":"https://api.github.com/repos/troydhanson/uthash/issues/150","id":372070315,"user":{"login":"silvioprog","id":1456829,"avatar_url":"https://avatars0.githubusercontent.com/u/1456829?v=4","gravatar_id":"","url":"https://api.github.com/users/silvioprog","html_url":"https://github.com/silvioprog","followers_url":"https://api.github.com/users/silvioprog/followers","following_url":"https://api.github.com/users/silvioprog/following{/other_user}","gists_url":"https://api.github.com/users/silvioprog/gists{/gist_id}","starred_url":"https://api.github.com/users/silvioprog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silvioprog/subscriptions","organizations_url":"https://api.github.com/users/silvioprog/orgs","repos_url":"https://api.github.com/users/silvioprog/repos","events_url":"https://api.github.com/users/silvioprog/events{/privacy}","received_events_url":"https://api.github.com/users/silvioprog/received_events","type":"User","site_admin":false},"created_at":"2018-03-10T21:56:12Z","updated_at":"2018-03-10T21:56:12Z","author_association":"NONE","body":"Phew, I left VS! However, I'll try to fix all errors reported by GCC's `-Wconversion` (this consequently solves the problems in VS, well... I think)."}}
{"actor":{"display_login":"silvioprog"}}