Live data from Hacker News

C extensions, portability, and alternative compilers

lemon.rip

51–60 of 97 posts

Re: C extensions, portability, and alternative compilers

#51
post #22

Earlier quoted context omitted.

MSVC support for C is fairly terrible. For the projects we write that are portable to Windows we insist you use GCC or Clang on Windows. No one has time to deal with the lack of even standard C1x/C2x features (never mind useful extensions like attribute cleanup). Surprised about FreeBSD. My experience is that porting Linux software is usually pretty easy as long as it's not using some Linux-only feature (io_uring for…

> Surprised about FreeBSD. My experience is that porting Linux software is usually pretty easy as long as it's not using some Linux-only feature (io_uring for instance). I'm not sure why you're surprised, the parent of you comment clearly stated "on FreeBSD you often run into systemd dependencies or other non-posix behaviors" which means, software written for Linux often uses "Linux-only features" such as systemd and…

Linux used to be a pretty good UNIX, I'm not sure what it is now.

Linux has become Linux, it's own thing that as often as not says "yeah, that old Unix stuff is fine for you boomers and other fossils...we're going to be over here doing our own thing". Which is probably fine, I guess, because all the old Unix versions did the same thing to some extent and the computing world had changed over a dozen times since Unix showed up. Unless you were on one of the minimally massaged System V reference ports, going from one vendor to another was anything between "lots of annoying differences that make life less fun than it could be" to "WTF said this was Unix and why did you make me touch it?". Ultrix, SCO and UTek (among many others) weren't awful. Solaris and HP/UX had some vendor-only things that were hard to replicate. AIX made you question your life choices, especially if you wandered off into one of the mainframe versions; you had clearly angered the gods.

There used to be Windows, Unix, and everything else. Now there's Windows, Linux, and everything else, with Unix (BSD mostly) being part of everything else. Times change, shit happens, and there's only so much that impotently shaking your fist at the unjust universe will fix.

Re: C extensions, portability, and alternative compilers

#52
I'm in the middle of targeting Dart C FFI for Jank lang. The Zig toolchain has been helpful for simplifying the complexity, similar to how Bun simplified JS devwork. This article is relevant as some libraries have to be considered in building the jank package with glib libraries on a Nix flake.

Re: C extensions, portability, and alternative compilers

#53
post #2

One of my pet-peeves with C projects is that it's so often more or less "works on my machine" when written by Linux users (as a Windows and FreeBSD user it often hits you on both those platforms). The article highlights a typical piece: #if !(defined __GNUC__ || defined __clang__ || defined __TINYC__) # define __attribute__(xyz) /* Ignore */ #endif There is no reason that !defined check to not include a check for __a…

systemd is indeed the bane of Linux, and a pain in the ass for a lot of FOSS. Once the main distributions made it mandatory to install (not just the default, but mandatory) - we've started to see this sort of bifrucation of a lot more FOSS away from being standard-based and multi-platform to being Linux-specific. That said - I think a rule-of-thumb one can follow is that any inclusion of a file with a directory prefi…

Nope. Systemd is pretty great. It's pretty well designed, fully featured, very easy to use and quite nice program against. And it's GPL licensed free software.

Systemd bothers people because it's not "the Unix way". In other words, it's not some painful lowest common denominator POSIX nonsense. That's a feature, not a bug. POSIX is garbage and restricting oneself to it is pure masochism.

Every unixlike deviates from POSIX and for good reason. That includes the BSDs, but somehow I don't see people complaining endlessly about all the nifty exclusive features they keep accumulating for themselves. Why is it that only Linux gets singled out?

Re: C extensions, portability, and alternative compilers

#55
post #40

Earlier quoted context omitted.

What do you even miss, honestly works fine for me? In terms of platform APIs, I prefer the Windows ones on Windows anyway

Complex numbers, for example. Also, C preprocessor expands macros differently on MSVC.

Use the new standards-conformant preprocessor with `/Zc:preprocessor`

https://learn.microsoft.com/en-us/cpp/build/reference/zc-pre...

Re: C extensions, portability, and alternative compilers

#56
post #34
post #30

Earlier quoted context omitted.

> And of course, once your code does not target just one single machine then you're forced to have to worry about portability and standard compliance etc. Well linux exclusively usages gcc to compile.

https://www.kernel.org/doc/html/latest/kbuild/llvm.html

Which was largely sponsored by Google, as they removed GCC from Android, and needed to have clang compile the Linux kernel.

For a long time only Android Linux kernel downstream supported it.

Re: C extensions, portability, and alternative compilers

#58

I think the Common Lisp ecosystem sets a good example of how a dozen of implementations move ahead together. Implementations experiment with extensions, the really useful ones get implemented multiple times, and some portability library emerges as de-facto standard if it's good enough. You can watch the result in https://portability.cl/ , the language is evolving like never before even if the standard committee has d…

Isn’t this only possible in lisp due to the strong foundations of meta programming allowing the implementation of language features as user libraries?

Re: C extensions, portability, and alternative compilers

#59
> For example, clang defines __GNUC__=4 (and __GNUC_MINOR__=2, __GNUC_PATCHLEVEL__=1) to claim compatibility with GCC 4.2.1.

Is this because Apple at some point stopped updating GCC because of the GPL license change? I think GCC 4.2.x was the last GCC licensed under GPLv2. Could be for compatibility reasons for Mac software.

Re: C extensions, portability, and alternative compilers

#60
post #22

Earlier quoted context omitted.

MSVC support for C is fairly terrible. For the projects we write that are portable to Windows we insist you use GCC or Clang on Windows. No one has time to deal with the lack of even standard C1x/C2x features (never mind useful extensions like attribute cleanup). Surprised about FreeBSD. My experience is that porting Linux software is usually pretty easy as long as it's not using some Linux-only feature (io_uring for…

> Surprised about FreeBSD. My experience is that porting Linux software is usually pretty easy as long as it's not using some Linux-only feature (io_uring for instance). I'm not sure why you're surprised, the parent of you comment clearly stated "on FreeBSD you often run into systemd dependencies or other non-posix behaviors" which means, software written for Linux often uses "Linux-only features" such as systemd and…

How is that Linux only features line different from OpenSSH (OpenBSD specific) vs Portable OpenSSH? If it bothered people that much they can also band together and make a Portable $whatever.
Post reply on HN