tinycpp icon indicating copy to clipboard operation
tinycpp copied to clipboard

preproc: implement support for directory-relative #include "..."

Open tmcintos opened this issue 2 years ago • 2 comments

(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.

tmcintos avatar May 12 '23 04:05 tmcintos

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)

rofl0r avatar May 12 '23 08:05 rofl0r

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.

tmcintos avatar May 12 '23 08:05 tmcintos