Pragma msg goes out of memory when supplied with large data.
Dennis
dkorpel at gmail.com
Fri May 23 13:10:47 UTC 2025
On Friday, 23 May 2025 at 12:06:00 UTC, realhet wrote:
> - export: It was possible to export data (20MByte) from the
> compiler in seconds, using pragma(msg, ...) Just don't touch
> the large data with CTFE.
pragma(msg) is meant to print informative human-readable strings
for debugging purposes. It's not designed for large data or
consistent results. A pull request to the compiler improving the
formatting of a pragma(msg) might break your setup.
Please carefully consider whether a convoluted build system is
worth it. I've done some cute GLSL+D metaprogramming as well in
the past with the goal to automatically bind uniforms and vertex
attributes between the two languages seamlessly, but I'm not
using it anymore because the impedance mismatch is too high.
I'm talking: Different alignments (std140 and std430), booleans
are 4 bytes, normalized and packed integers need special types on
the D side, vec3 and float[3] both exist in OpenGL, there's 36
sampler types, OpenGL's reflection API has holes (you can't query
the pixelformat from `layout(binding=2, rg32f)`), column/row
major matrix layout etc.
This results in a complex system that's more annoying to deal
with than the original problem of just maintaining a .d file and
shader file in parallel, which is what I'm doing now for the time
being.
... but if that didn't scare you off, you can use `__ctfeWrite` 😉
```D
string f(string s) { __ctfeWrite(s); return s; };
enum x = f("Hello world\n"); // prints "Hello World\n" to stderr
```
I recommend keeping it simple, cover common cases and don't try
to make it perfect, because it won't be. But if you do somehow
make it perfect, post your results, I'd love to see it!
More information about the Digitalmars-d-learn
mailing list