4 ms·
When you think about using the library from languages which don't link against libc by default (Go for example), then this is a significant difference.
by _ph_ 5y ago
When you think about using the library from languages which don't link against libc by default (Go for example), then this is a significant difference.
- masklinn 5y agoHow does Go have any relevance? This is a C program, it will link against libc.
- R0b0t1 5y agoThe example is still relevant, say if your program has no OS.
- masklinn 5y ago> The example is still relevant, say if your program has no OS. Not only does it seem unlikely your program would have a terminal output and standard streams without having an OS, bestline still requires a libc. Just open `bestline.c` and you'll find: #include <termios.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <errno.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <unistd.h> #include <setjmp.h> #include <poll.h> #include <assert.h> #include <signal.h> #include <fcntl.h> #include <limits.h>
- R0b0t1 5y agoYou've never used a microcontroller. They are usually shipped with a partial libc that binds fd 0/1 to a USART. Sometimes POSIX threads can be mapped to FreeRTOS calls. Most of the defines can have a null implementation and the core will still work. They just need to be defined.
- masklinn 5y agoYou’re not making any sense. If the system provides a libc stub then printf and whatever are not concerns, they’ll just go through the stub. And the message I quoted says literally nothing about µc.
- _ph_ 5y agoYou can easily call C libraries from languages like Go and Rust. It absolutely makes sense to write small libraries in C so that all kind of languages can use the library which are not C. Go programs by default do not link against libc, so it would be nice not introducing the dependency. So this would fall under "nice to have".
- drran 5y agoWhy I need to use readline on a system without libc, e.g. a heavily optimized container?
- masklinn 5y agoBestline does not work without a libc, you can just open the main c file and see that it’s full of libc #includes.