https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64094
--- Comment #5 from Jon Grant <jg at jguk dot org> --- Hi Manu I like your open_strerror() propopsal. Is this how Bintuils has done it? Note: I realise this problem stems from ENOENT being used by both opendir() and open(). I think you only need to provide two wrappers to handle these cases Note: %m is not ideal in my view as it is a C Library extension that I believe is not widely supported. could it be replaced with %s? http://www.gnu.org/software/libc/manual/html_node/Other-Output-Conversions.html Alternatively, could have a check where files are stat() before they are opened, and then report the error then. Likewise for directories.