tinycpp
tinycpp copied to clipboard
preproc: implement support for directory-relative #include "..."
(cherry picked from commit 9d3ebe3837c66c2e22a1182ec3a8d35bca5fcbab)
I needed file-relative includes via #include "..." to work for my application, so I worked out a way of doing this.
Hope this may be of use. Thanks for creating this amazing project!
NOTE: I forgot I left a DEBUG print in here which may not be wanted, but was convenient for me when confirming that this worked as expected.
this seems kinda hackish, maybe we should just always add "." as first entry upon creation of the cpp context, but only use it if the include starts with " (i.e. in tglist_foreach depending on whether i == 0 and path[0] == '"', else continue)
Yeah, that may be better. I definitely didn’t like having to insert the item in the list and remove it again, but I was just looking for the most surgical change I could make to enable my use case.
I don’t have a strong opinion on it as long as it works.