Reads linker error output, and gives a "no main function specified" error when proper.
added no-main-error detection
fixed a few bugs
This seems reasonable to me and is sorely needed - a lot of people are confused when they see a bunch of seemingly nonsensical linker errors just because they forgot main.
This does make some assumptions about the output of the linker, but I don't think that's a problem for all practical purposes. Though, is this tested on all the platforms listed in that #if?
@alexrp I've only tested it on my OSX machine. However, it's all POSIX, so any standards-compliant platform should work.
EDIT: now that I think about it, ld isn't POSIX. So no.
I was more curious whether the error detection works everywhere than anything else.
@alexrp If it doesn't detect the error, it outputs the linker error as it's always done.
Sure, and that's fine; I'm just wondering if it will actually catch the missing main error on all three POSIXes that we currently support (Linux, OS X, FreeBSD) or if this was only tested on a particular system.
@alexrp I tested it on Debian, there's a different error message. I'll try and make it check for that.
Testing on other platforms, will reopen when done.
added support for other operating systems
Converted from feof() to EOF
Tested on Debian, modified so that error messages on other platforms can be easily added in.
continued with feof -> EOF
merge D2 pull #1178
The strategy of this is great, but the implementation is awkward and deviates (I think) a bit from dmd's usual style as I'll note inline.
@andralex This is an earlier commit; I fixed some of the issues you mentioned, but not all of them. The ones I still need to work on:
I don't want to return true when nmeFound, because I still need to forward the rest of the error message. In later commits I break to the no-checking forwarding loop.
How would converting the last loop to using fread work? I'm assuming read/write a buffer. What should its size be?
Should I create another pull request which handles these three things?
Thanks for your understanding. Sorry for misinterpreting the logic where I did. For fread/fwrite, just use a stack-allocated 64 KB buffer. Feel free to create an additional pull request - aside from the error checking issue, there's no urgency.
move definition to point of initialization
move to after the test against stream
must return here!
static const char nmeErrorMessage = " \"__Dmain\", referenced from:";
must check for errors
move definition to initialization
This fgetc/fputc approach is very slow. Should we invest in switching to fread/fwrite?
Ooh. Can we use the linker pipe to also demangle D symbols from linker errors on the fly?
@CyberShadow What a great idea!!!
Calling waitpid without emptying the pipe buffer causes a deadlock for huge error messages.