Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8609

General • Re: How to report compile time values ?

$
0
0
#if TOTAL != <expected value>
_Static_assert (TOTAL == 1, "TOTAL does not have expected value");
Thanks, and for the explanation why the first, and what I was doing, doesn't work.

The problem with both is that I don't know what TOTAL should be in advance for the various options I can set in the original code.

I was hoping to try various combinations in the original code, compile those, and see what values I got for each. Then compile the ported code and confirm the values match.

I guess I can compile the original with various combinations and report what the values are at run time, then set the ported code expected values and compile those. It's more involved than I was hoping for but should work.

The reason I can't report from the ported code at run time is that I can't connect because it's USB descriptor related, and I'd like to know if that's because I have messed up my 'enum' conversions or something else.

I could potentially connect up a UART but but imagined I could simply convince the compiler to tell me what values were being used. I guess I could concoct some assignment and then see what value is being loaded in a disassembly.


Lightbulb moment : I can compile the code for Pi hosting, run it on a Pi where it won't actually use USB, but can print run-time values.

I was also hoping to have something like -

Code:

char * info[] = {  "You have used " STR(TOTAL) " things",  "More things",};
And I guess that's not going to work with 'enum', only '#define'.

Statistics: Posted by hippy — Sat Mar 16, 2024 8:51 pm



Viewing all articles
Browse latest Browse all 8609

Trending Articles