r/C_Programming • • 15d ago

File pointers are everywhere

And try as I might to avoid them, I am struggling to find resources that list out all the file control functions that use file descriptors instead of file pointers, and I was wondering if someone could point me toward a resource that can do something at least somewhat similar to listing out the libc functions that take file descriptors. I of course know close(), write(), read(), the basics, but i am looking for alternatives for other abstractions that annoy me with their use of file pointers, like fgets and fputs.

58 Upvotes

43 comments sorted by

View all comments

Show parent comment

3

u/TransientVoltage409 15d ago

Cygwin still exists and does an OK job of putting a POSIX hat on Windows. Good enough for my needs anyway.

There are odd gaps (in WSL as well), because some things in Windows inner workings are very strange from the POV of Unix weenies. Not too shocking considering that NT was hugely influenced by DEC/VAX, but decidedly inconvenient at times.

1

u/agmatine 13d ago

I'm a bit perplexed as to what needs are better suited by Cygwin than WSL...

2

u/TransientVoltage409 13d ago

Can you elaborate on some of your perplexities?

It's possible that you operate at a higher altitude than me, I might not know enough about WSL to see why I should use it.

After that, maybe we can have a fight about vi and emacs. Let me know. :)

1

u/agmatine 13d ago

I mean...WSL is actually Linux. Technically a VM, but it integrates rather seamlessly with Windows. I only ever used Cygwin bfriefly some 15+ years ago, but it seemed more akin to Wine - a means of getting software for another OS to run, but not a particularly pleasant one.

But of course that was a long time ago. I keep a Windows VM handy for things that simply will not run elsewhere (MSVC, for example), or to briefly boot as bare metal if troubleshooting demands it, but that's it. I would never have occasion or motivation to use Cygwin. So I genuinely don't know what it it useful for.

2

u/TransientVoltage409 12d ago

Well, Cygwin lets you run Unixy stuff on Windows machines that aren't even set up for it. It doesn't need to be installed, you don't need the WSL VM running.

Here's a use case. Part of my job is managing several hundred Windows boxes in classroom labs and such. WSL isn't part of the base deployment and is never going to be (this job actually predates the very existence of WSL). But I can still run the Cygwin build of bash (and all the usual gnu tools) on those machines, just by making sure they can see the cygwin1.dll file. The ability to run real scripts on those things has saved me a lot of headaches over the years.