Abusing C macros to render the Mandelbrot Set at compile-time
1–10 of 23 posts
Re: Abusing C macros to render the Mandelbrot Set at compile-time
#2 $ pbpaste | time clang -x c -
99.35 real 82.72 user 9.94 sys
If you're using iTerm, you can pipe the output of the program to imgcat to see the result without leaving your terminal.Re: Abusing C macros to render the Mandelbrot Set at compile-time
#3Re: Abusing C macros to render the Mandelbrot Set at compile-time
#4Just as a FYI, this takes a while to compile: $ pbpaste | time clang -x c - 99.35 real 82.72 user 9.94 sys If you're using iTerm, you can pipe the output of the program to imgcat to see the result without leaving your terminal.
Re: Abusing C macros to render the Mandelbrot Set at compile-time
#5Here's a link of the output image: https://imgur.com/cUdForu
Re: Abusing C macros to render the Mandelbrot Set at compile-time
#6"virtual memory exhausted: Cannot allocate memory"
when trying to compile :/
Re: Abusing C macros to render the Mandelbrot Set at compile-time
#7The pre-processor outputs 76,385,728 chars on 546 lines
Re: Abusing C macros to render the Mandelbrot Set at compile-time
#8This is really neat. I changed the quality value to 6: clang took ~20 minutes to compile and it used around 32GB of RAM. The resulting executable is 13KB, and it generates a 4KB image as output. Here's a link of the output image: https://imgur.com/cUdForu
It's 64x64.
Re: Abusing C macros to render the Mandelbrot Set at compile-time
#9Can we please have constexpr in C 2x to put an end to this madness?
That said I absolutely don't disagree with you at all. It's really a bit silly C doesn't have it at this point. `gcc` will happily do all of this math for you at compile time even if you do as much of the math as you can in `static` functions. But to make it compile you have to declare `pixels` in `main` because you can't call the functions in the initializer for file-scoped variables - even though the compiler can already optimize them out.