Compile Error Trying to Use getopt()

Status
Not open for further replies.
Just my personal opinion:

I don't think it makes sense to "fix" anything here. If one wants to use any function from the standard library which needs to write / read from the standard streams in an embedded environment he necessarily has to tell libc how he intends to do that. Libc can not know if you want to display it on an attached display, some UART or printing the text on a 3d printer. This is exactly why libc requires_write and _read to be defined by the user in embedded systems.

I also don't think it is a good idea do introduce dummy functions here. They will just make the linker error go away. E.g. if you have a dummy _write(). printf() would perfectly compile but wouldn't print. That would probably generate more questions from inexperienced users than having the linker error which shows them "printf doesn't work on this system". For experienced users it is no problem at all to provide implementations of _write / _read so they can use the library functions if they want.

I suggest to leave everything as it is now because this seems to be the indented behavior, it doesn't confuse beginners and it is easy to make it run for experienced users.

Just my thoughts...

+1, I fully second that!
 
I also don't think it is a good idea do introduce dummy functions here. They will just make the linker error go away. E.g. if you have a dummy _write(). printf() would perfectly compile but wouldn't print. That would probably generate more questions from inexperienced users than having the linker error which shows them "printf doesn't work on this system". For experienced users it is no problem at all to provide implementations of _write / _read so they can use the library functions if they want.
mk20dx128.c in cores is 'full' of such dummy functions (only to keep compiler/linker happy?). Interestingly, there are _read, _close, even _lseek (sic) and others, but no _open and no _write.
Sometimes, it would be nice to have a complete and forward looking cores library.
 
Status
Not open for further replies.
Back
Top