Should we allow relative includes? (i.e. #include "../_ssl.h")
Feature or enhancement
Proposal:
Can we avoid the relative include? They tend to produce problems further down the road.
Originally posted by @erlend-aasland in https://github.com/python/cpython/pull/120894#discussion_r1658402167
There are few more examples:
$ git grep '#include .*\.\.\/'
Include/internal/mimalloc/mimalloc/track.h:#include "../src/prim/windows/etw.h"
Modules/_blake2/blake2b_impl.c:#include "../hashlib.h"
Modules/_blake2/blake2s_impl.c:#include "../hashlib.h"
Modules/_ctypes/callproc.c:#include "../_complex.h" // complex
Modules/_hacl/internal/Hacl_Hash_MD5.h:#include "../Hacl_Hash_MD5.h"
Modules/_hacl/internal/Hacl_Hash_SHA1.h:#include "../Hacl_Hash_SHA1.h"
Modules/_hacl/internal/Hacl_Hash_SHA2.h:#include "../Hacl_Hash_SHA2.h"
Modules/_hacl/internal/Hacl_Hash_SHA3.h:#include "../Hacl_Hash_SHA3.h"
Modules/_ssl/cert.c:#include "../_ssl.h"
Modules/_ssl/misc.c:#include "../_ssl.h"
Modules/_testinternalcapi/set.c:#include "../_testcapi/util.h" // NULLABLE, RETURN_INT
Objects/mimalloc/prim/osx/prim.c:#include "../unix/prim.c"
Parser/lexer/lexer.c:#include "../tokenizer/helpers.h"
Parser/tokenizer/file_tokenizer.c:#include "../lexer/state.h"
Parser/tokenizer/file_tokenizer.c:#include "../lexer/lexer.h"
Parser/tokenizer/file_tokenizer.c:#include "../lexer/buffer.h"
Parser/tokenizer/helpers.c:#include "../lexer/state.h"
Parser/tokenizer/helpers.h:#include "../lexer/state.h"
Parser/tokenizer/readline_tokenizer.c:#include "../lexer/lexer.h"
Parser/tokenizer/readline_tokenizer.c:#include "../lexer/state.h"
Parser/tokenizer/readline_tokenizer.c:#include "../lexer/buffer.h"
Parser/tokenizer/string_tokenizer.c:#include "../lexer/state.h"
Parser/tokenizer/utf8_tokenizer.c:#include "../lexer/state.h"
Python/Python-tokenize.c:#include "../Parser/lexer/state.h"
Python/Python-tokenize.c:#include "../Parser/lexer/lexer.h"
Python/Python-tokenize.c:#include "../Parser/tokenizer/tokenizer.h"
Python/Python-tokenize.c:#include "../Parser/pegen.h" // _PyPegen_byte_offset_to_character_offset()
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Note that mimalloc is copied from upstream, I don't think we should be changing it here.
Same for HACL*.
It seems like we have multiple C files using relative includes, and I'm not aware of any practical issue, so I suggest to simply closing this issue.
@erlend-aasland, could you more elaborate about problems, mentioned in your comment?
@erlend-aasland, could you more elaborate about problems, mentioned in your comment?
I don't remember the reason for raising this issue. I'm fine with closing the issue, as Victor suggests.