Earlier quoted context omitted.
Unless you also need to free, it's pretty simple.
Of course. When I wrote that comment I asked myself should I have written "malloc" or "malloc/free" - surely one implies the other.
Writing C software without the standard library
91–100 of 188 posts
Re: Writing C software without the standard library
#92Earlier quoted context omitted.
Yeah off topic but if HN supported markdown (and GitHub's flavor of markdown so we could take different types of syntax with their language) would be amazing. There would be a ton more coding examples and discussion, in my opinion, if this were to happen. How do we summon Dang? :)
my netiquette says, more than about three lines of code should go in a pastebin anyway
tldr; practicality and longevity should trump netiquette.
Re: Writing C software without the standard library
#93He claims that your code will be easy to port but then goes straight to Linux system calls. Still I like the idea. This is something that should be covered in a CS 102 type course. I know way to many cs guys who have no idea how to debug, let alone how their is being implemented.
As far as PortableOSIX compliant syscalls are concerned, they are literally portable.
POSIX only specifies a set of C library functions. Once you stop using them, you are on your own.
Re: Writing C software without the standard library
#94Earlier quoted context omitted.
Win32 is itself a layer on top of the syscalls, and already provides much of the functionality of the C standard library.
Yes, that was partly my point. You can get reduced executable size and a lack of dependencies on various msvc*.dlls, without giving up much of the functionality of the C standard library and without having to write it all yourself.
Re: Writing C software without the standard library
#95Re: Writing C software without the standard library
#96Earlier quoted context omitted.
Yes, that was partly my point. You can get reduced executable size and a lack of dependencies on various msvc*.dlls, without giving up much of the functionality of the C standard library and without having to write it all yourself.
Fine, but you get this thanks to already being linked with these megagodzillas like kernel32.dll. Try without them.
Re: Writing C software without the standard library
#97A value in the range between -4095 and -1 indicates an error, it is -errno. The syscall/errno stuff has always seemed unusual, inelegant, and inefficient --- instead of just returning a negative error code directly, the function returns the vague "an error has occurred" -1, and you have to then check errno separately after that. It only adds insult to injury when you realise that the kernel itself isn't doing it, but…
> At least on Linux the first few (i.e. the oldest, most common and useful) syscalls have not really moved around over the years IIRC raw syscalls are an officially supported kernel API, that's why you can have alternate libc implementations (e.g. musl), and Linux is an oddity in that, on most systems even if the syscalls are fairly stable there are no actual guarantees with respect to them, and the only officially s…
Re: Writing C software without the standard library
#98Well, I've already learned something new. I assumed that convention was from the compiler. This is a great resource.
Re: Writing C software without the standard library
#99Earlier quoted context omitted.
Yeah off topic but if HN supported markdown (and GitHub's flavor of markdown so we could take different types of syntax with their language) would be amazing. There would be a ton more coding examples and discussion, in my opinion, if this were to happen. How do we summon Dang? :)
my netiquette says, more than about three lines of code should go in a pastebin anyway
Re: Writing C software without the standard library
#100He claims that your code will be easy to port but then goes straight to Linux system calls. Still I like the idea. This is something that should be covered in a CS 102 type course. I know way to many cs guys who have no idea how to debug, let alone how their is being implemented.
When I was learning C, I loved Plauger's book on the standard library for just that reason; it's very informative to be guided through the implementation of the whole thing, not only to see how it works, but it's also a good way just to be introduced to everything in it without any magic. It's an excellent 2nd book on C, I think.
I discovered a little book by him after wading thru recursive descent parsers chapter by Herb Schildt... I don't want to get down on Schildt, I enjoyed that too, he showed some cool stuff..
but Plauger had me thinking that programming could be a craft, an art, a noble intellectual pursuit.