Hi,
Dave Jones (from the EEVblog) just released a video series to Patreons about programming the Paduk microcontrollers. During the series he uses SDCC and hits the error 'fopen' failed on file 'test.asm', which after a while he figures out is due to running sdcc inside a directory with limited permissions (Inside Program Files on Windows).
I've hit similar issues with tools before, so here's a patch that includes the operating system error (and if the file is an input or output) when fopen fails. Maybe it'll save somebody some time in the future :)
Old error message example:
$ sdcc test.c
test.c:2: error 4: 'fopen' failed on file 'test.asm'
New error message example:
$ sdcc test.c
test.c:2: error 257: Failed to open output file 'test.asm' (Permission denied)
Changes:
* Add E_OUTPUT_FILE_OPEN_ERR and E_INPUT_FILE_OPEN_ERR error types, which contain a second string
* Change all cases of E_FILE_OPEN_ERR to one of the above, including strerror(errno) when available
* Change one E_FILE_OPEN_ERR to E_UNKNOWN_TARGET in pic14/pcode.c so the error makes more sense
The reason I introduced two new error codes, rather than reusing the existing error, is to keep the existing API unchanged, incase there is out-of-tree code that use E_FILE_OPEN_ERR.
Thanks. I've just watched the video, now that it is no longer paywalled.
If no other SDCC developer handles it first, I'll have a closer look at the patch next week.
Thanks. Applied in [r11617].