Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 3-1-1 and constant declarations
#2
IMHO, yes, in a strict sense this is a violation. Even if it is a constant, the construct is a definition, and it depends (among others) on the compiler whether the object will occupy storage. You could also create a pointer to such an object, in which case it has to occupy storage.
The compliant way to provide such constants would be to provide a declaration
extern const uint8 PLD_READ_VERIFICATION_BYTE_4;
in a header file, and provide one C file with the definition you provided.
Alternatively, you could also define a documented exception and remain compliant, albeit using a deviations documentation.

Be aware that providing constant definitions in a header file makes you rely on a linker property (outside of the strict scope of the C/C++ Standards), called the "Omitted Storage Class Model" (For C, see Harbison/Steele 5th edition, section 4.8), a property that is common for linkers to have, but several linkers can also be configured to support a different model.
Note that the above described 'compliant way' will produce identical results using any model.

HTH,

Johan
<r>Johan Bezem<br/>
Email: <EMAIL email="[email protected]">[email protected]</EMAIL><br/>
Tel: +49 172 5463210<br/>
Web: <URL url="http://www.bezem.de/">http://www.bezem.de/</URL></r>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)