Regularized #include under include/mruby/*.h#3032
Regularized #include under include/mruby/*.h#3032pbosetti wants to merge 1 commit intomruby:masterfrom
Conversation
https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html According to C Preprocessor syntax, the #include "file" syntax first searches in the directory containing the current file, then in the quote directories and then the same directories used for <file>. The 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).
|
I'd rather refer headers by |
|
@matz bear with me and please forgive me for insisting, but your answer looks contrary to the intended usage for #include as explained by the GCC preprocessor manual. Including the file in the very local directory is what you want. Conversely, using angle brackets means "go search for IMHO, using angle brackets rather than using double quotes with local path has a possible issue when the user has another version of mruby installed in the system path, because in this case the headers under I still think that using e.g. Thanks, |
|
|
|
@matz: Let's make this example. Suppose that the file #include "common.h"
#include "compile.h"at lines 10 and 11. When he needs to include Conversely, with the current code at lines 10 and 11 of #include <mruby/common.h>
#include <mruby/compile.h>it still works, but there is the risk that, if the user has something like Again, 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. |
|
For internal headers, e.g. If you have a real error case (not theoretical one), I'd happy to be corrected. |
|
@matz I have made a real case here: https://gist.github.com/pbosetti/152379270f53d2386643 The example script shows how using local include commands in mruby headers (when they refer each other and by using relative paths to the current file) the user only has to add the main header folder to the headers path (with Conversely, with the current code in HEAD, this solution would not work and the user has to needlessly add another I am aware that there are other ways for solving the same problem, but using local includes in mruby headers has the following advantages:
|
According to C Preprocessor syntax (see the manual), the
#include "file"syntaxThe original call, e.g.
#include "mruby/common.h"from within the mruby folder, requires to have-Ipath/to/mruby/include/mrubyin compilation (which is not always the case).Conversely, the current PR is always working (i.e. regardless compilation switches), because
mruby/array.his always able to find#include "common.h"since it is in its same directory.