News for hackers. Stuff that matters.
Re:C4: C in Four Functions (2014) by jacobvosmaer on Tuesday February 18, 2020 @03:01AM (#22354283)
Clang on my macOS doesn't like the fact that main() takes and returns long long. But it appears GCC on Debian 8 (random linux I have lying around) doesn't mind.

I get it to compile on macOS if I remove the int define but then it segfaults when you run it. I wonder if there is some magic flag to make "main does not return int" a non-fatal error on Clang?

It's fun to read this code but running it is even more fun, you can see the VM code it generates, with source line annotations and all.

Re:C4: C in Four Functions (2014) by flohofwoe on Tuesday February 18, 2020 @05:02AM (#22354786)
The "#define int long long" is annoying indeed. A quick hack to make it work is:

#include <stdint.h>

...and then replace the two "int" in main() with int32_t.

Re:C4: C in Four Functions (2014) by psychoslave on Thursday February 20, 2020 @09:37AM (#22375339)
Doesn't that make it fail to maintain the self hosting property that is most likely behind the introduction of this define?
Re:C4: C in Four Functions (2014) by keanzu on Tuesday February 18, 2020 @03:35AM (#22354425)
For mac users: gcc -Wno-all -arch i386 -o c4 c4.c

https://news.ycombinator.com/item?id=8560127

You can compile it on 64 bit OS X with clang's -m32 option and it should work.

https://news.ycombinator.com/item?id=8559044

Re:C4: C in Four Functions (2014) by saagarjha on Tuesday February 18, 2020 @04:13AM (#22354577)
Neither of those work with a recent toolchain :(
Re:C4: C in Four Functions (2014) by coolreader18 on Tuesday February 18, 2020 @10:47AM (#22356830)
I just undef'ed and re-define-d int before and after the main declaration with clang, and it seems to work fine.