{"action":"opened","issue":{"url":"https://api.github.com/repos/irods/irods/issues/2950","labels_url":"https://api.github.com/repos/irods/irods/issues/2950/labels{/name}","comments_url":"https://api.github.com/repos/irods/irods/issues/2950/comments","events_url":"https://api.github.com/repos/irods/irods/issues/2950/events","html_url":"https://github.com/irods/irods/issues/2950","id":115028649,"number":2950,"title":"C code broken by rodsErrorTable.h's #defines to const ints change","user":{"login":"jmarshall","id":70921,"avatar_url":"https://avatars.githubusercontent.com/u/70921?v=3","gravatar_id":"","url":"https://api.github.com/users/jmarshall","html_url":"https://github.com/jmarshall","followers_url":"https://api.github.com/users/jmarshall/followers","following_url":"https://api.github.com/users/jmarshall/following{/other_user}","gists_url":"https://api.github.com/users/jmarshall/gists{/gist_id}","starred_url":"https://api.github.com/users/jmarshall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmarshall/subscriptions","organizations_url":"https://api.github.com/users/jmarshall/orgs","repos_url":"https://api.github.com/users/jmarshall/repos","events_url":"https://api.github.com/users/jmarshall/events{/privacy}","received_events_url":"https://api.github.com/users/jmarshall/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-04T11:05:06Z","updated_at":"2015-11-04T11:05:06Z","closed_at":null,"body":"In releases up to the current 4.1.6 and in the 4-1-stable branch, [rodsErrorTable.h](https://github.com/irods/irods/blob/4-1-stable/iRODS/lib/core/include/rodsErrorTable.h) looks like this:\r\n\r\n\t#define SYS_SOCK_OPEN_ERR                           -1000\r\n\t#define SYS_SOCK_BIND_ERR                           -2000\r\n\t…\r\n\r\nHowever on **master** as of f189815174ea9d9d19dc336f10d25494630b78e8 it lists these error names as `const ints` rather than `#defines`:\r\n\r\n\t#define NEW_ERROR(err_name, err_code) const int err_name = err_code;\r\n\t…\r\n\tNEW_ERROR(SYS_SOCK_OPEN_ERR,                           -1000);\r\n\tNEW_ERROR(SYS_SOCK_BIND_ERR,                           -2000);\r\n\t…\r\n\r\nThis breaks C code that uses these named errors in `switch` statements, e.g.,\r\n\r\n\tint status_errno(int status) {\r\n\t    switch (status) {\r\n\t    case CAT_NO_ROWS_FOUND: return ENOENT;\r\n\t    case CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME: return EEXIST;\r\n\t    …\r\n\r\nas a `const int` is not an _integer constant expression_ in C so can't be used as a `case` value.\r\n\r\nIt would be useful for those writing iRODS clients in C if this could be reverted to a list of `#defines`.  Alternatively (as there is benefit in having these names available to the compiler and debugger) the `NEW_ERROR` macro could be changed to build up an `enum` containing the list.  Enumerators are valid for `case` in both C and C++."}}