3 ms·
Could you expand on this? I don't understand the point you're making, or how it's useful.
by Panzer04 2y ago
Could you expand on this? I don't understand the point you're making, or how it's useful.
- whitten 2y agoPerhaps a distinction between static analysis (at compile) and dynamic analysis (at run time) is useful ?
- ijustlovemath 2y agostatic consts in C carry their identity through their (fixed, unchanging) pointer address. Lets say you have a business rules engine, that's only meant to ingest threshold values from a certain module. You want to know if the 3.0 you're using is coming from the correct place in the code, or if there's a programming error. With a define, there's not enough additional information to be able to. With a static const, you can just have a const static array of pointers to the valid threshold constants, and use that in your tests for the rules engine. I work in a highly regulated field, so often this level of paranoia and proof helps us make our case that our product works exactly the way we say it works.
- Panzer04 2y agoSo it's easier to guarantee the identity is correct? That doesn't stop you from using the incorrect identity, though. I'm not quite sure I understand how this is better than a define - if you know enough to know whether you're using the correct value, it can just as easily be a define? I think I can see the idea, but I'm probably not paranoid enough to understand how it's helpful XD