{"action":"created","issue":{"url":"https://api.github.com/repos/mruby/mruby/issues/3032","labels_url":"https://api.github.com/repos/mruby/mruby/issues/3032/labels{/name}","comments_url":"https://api.github.com/repos/mruby/mruby/issues/3032/comments","events_url":"https://api.github.com/repos/mruby/mruby/issues/3032/events","html_url":"https://github.com/mruby/mruby/pull/3032","id":118339042,"number":3032,"title":"Regularized #include under include/mruby/*.h","user":{"login":"pbosetti","id":53605,"avatar_url":"https://avatars.githubusercontent.com/u/53605?v=3","gravatar_id":"","url":"https://api.github.com/users/pbosetti","html_url":"https://github.com/pbosetti","followers_url":"https://api.github.com/users/pbosetti/followers","following_url":"https://api.github.com/users/pbosetti/following{/other_user}","gists_url":"https://api.github.com/users/pbosetti/gists{/gist_id}","starred_url":"https://api.github.com/users/pbosetti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pbosetti/subscriptions","organizations_url":"https://api.github.com/users/pbosetti/orgs","repos_url":"https://api.github.com/users/pbosetti/repos","events_url":"https://api.github.com/users/pbosetti/events{/privacy}","received_events_url":"https://api.github.com/users/pbosetti/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-11-23T08:46:23Z","updated_at":"2015-11-27T16:28:30Z","closed_at":"2015-11-27T08:48:36Z","pull_request":{"url":"https://api.github.com/repos/mruby/mruby/pulls/3032","html_url":"https://github.com/mruby/mruby/pull/3032","diff_url":"https://github.com/mruby/mruby/pull/3032.diff","patch_url":"https://github.com/mruby/mruby/pull/3032.patch"},"body":"According to C Preprocessor syntax (see [the manual]( https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html)), the `#include \"file\"` syntax \r\n> searches for a file named `file` first in the directory containing the current file, then in the quote directories and then the same directories used for `<file>`.\r\n\r\nThe original call, e.g. `#include \"mruby/common.h\"` from within the mruby folder, requires to have `-Ipath/to/mruby/include/mruby` in compilation (which is not always the case).\r\n\r\nConversely, the current PR is always working  (i.e. regardless compilation switches), because `mruby/array.h` is always able to find `#include \"common.h\"` since it is in its same directory."},"comment":{"url":"https://api.github.com/repos/mruby/mruby/issues/comments/160170734","html_url":"https://github.com/mruby/mruby/pull/3032#issuecomment-160170734","issue_url":"https://api.github.com/repos/mruby/mruby/issues/3032","id":160170734,"user":{"login":"pbosetti","id":53605,"avatar_url":"https://avatars.githubusercontent.com/u/53605?v=3","gravatar_id":"","url":"https://api.github.com/users/pbosetti","html_url":"https://github.com/pbosetti","followers_url":"https://api.github.com/users/pbosetti/followers","following_url":"https://api.github.com/users/pbosetti/following{/other_user}","gists_url":"https://api.github.com/users/pbosetti/gists{/gist_id}","starred_url":"https://api.github.com/users/pbosetti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pbosetti/subscriptions","organizations_url":"https://api.github.com/users/pbosetti/orgs","repos_url":"https://api.github.com/users/pbosetti/repos","events_url":"https://api.github.com/users/pbosetti/events{/privacy}","received_events_url":"https://api.github.com/users/pbosetti/received_events","type":"User","site_admin":false},"created_at":"2015-11-27T16:28:30Z","updated_at":"2015-11-27T16:28:30Z","body":"@matz: Let's make this example. Suppose that the file `include/irep.h` has \r\n```C\r\n#include \"common.h\"\r\n#include \"compile.h\"\r\n```\r\nat lines 10 and 11. When he needs to include `irep.h` in his own code, the user needs to `#include <mruby/irep.h>` (**as you like to have as API**), and to add `-I./local/path/to/mruby/include` to the compiler flags. It simply works, and the file `irep.h`, in turn, is including the files `common.h` and `compile.h` that are within `./local/path/to/mruby/include/mruby` (exactly what is intended to do).\r\n\r\nConversely, with the current code at lines 10 and 11 of `include/irep.h`:\r\n```C\r\n#include <mruby/common.h>\r\n#include <mruby/compile.h>\r\n```\r\nit still works, but **there is the risk** that, if the user has something like `/usr/local/include/mruby/common.h` installed in his system the C preprocessor includes that file rather than the intended one under `./local/path/to/mruby/include/mruby`. If the installed version is different from the local one, the result can be unexpected and even difficult to debug.\r\n\r\nAgain, using the local include is not changing the API in any way, it is just making the code stronger w.r.t. different possible build conditions.\r\n\r\n\r\n\r\n "}}