Question

g++ verifies predetermined set of rules and constraints which if not met in code throws an error or warning messages. Is it possible using some tool to create a parser for custom set of rules such as "global variables need to be explicitly initialized" (I know global variables are implicitly initialized), or functions with name init has been called (I know about constructors but don't want to use them). Any pointers to something quick and simple would be useful.

Was it helpful?

Solution

Coverity lets you write custom rules like this. It's kind of expensive, so probably not a hobby kind of thing to set up just for this. It's a good tool for production code, though, and extensible.

OTHER TIPS

CLANG is a static code analyser used to insure that you wrote what you meant, even if what you wrote would compile anyway. It does sttic code analysis only.

Otherwise use assert() or exceptions to enfore rules at runtime.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top