danmar / simplecpp

C++ preprocessor
BSD Zero Clause License
204 stars 80 forks source link

`#include` pointing to directory is treated as existing empty file #343

Open firewave opened 7 months ago

firewave commented 7 months ago

If an include points to an existing directory (e.g. #include </>) the code will not raise an error. I would expect it to report EXPLICIT_INCLUDE_NOT_FOUND.

This is caused by using std::ifstream::is_open() to determine the existence of a file. But if you do this on a directory it will be successful as well as the subsequent read. It will not read anything though so it behaves like an empty file.