Finding out the value of const evaluation at compile time

Hi there

Is there any way Rust compiler could print the value of a const at compile time? In a note perhaps?

This might be an XY problem, so here's the whole story:

I'm currently in the process of creating my own kernel in Rust for RPi 4B. I find it somewhat tedious to check the data structures I initialize with const fns. It's difficult to use #[test], because the binary is being cross-compiled for ARMv8, and asm! macros make it close to impossible to test anything on x86, without adding a buttload of #[cfg(not(test))] lines.

I'm looking for a way to find the value of const without having to resort to memory dumps from jtag / readelf / hexdumps.

I find this is similar to A macro to print into log of the compiler during compile time?, albeit I doubt whether the solution proposed there fits my needs.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.