c++ - How to hide the register address in a class -


i creating driver , have declared registers in header file of class.

private:  static const uint32_t reg1 = (0x00000000); static const uint32_t reg2 = (0x00000004); static const uint32_t reg3 = (0x00000008); static const uint32_t reg4 = (0x0000000c); static const uint32_t reg5 = (0x00000010); // etc ... 

then in .cpp, have done this:

const uint32_t class::reg1; const uint32_t class::reg2; const uint32_t class::reg3; const uint32_t class::reg4; const uint32_t class::reg5; 

i have been told need hide register values , don't put them header. optimal way this?

one way put them in anonymous namespace in source file class, dropping them header (and class) entirely:

namespace /*no name mean it's anonymous namespace*/ {     const uint32_t reg1 = ( 0x00000000);     /*etc*/ } 

i've dropped static it's no longer necessary.

that way, accessible particular compilation unit.


Comments

Popular posts from this blog

java - Unable to make sub reports with Jasper -

Save and close a word document by giving a name in R -

scala - play framework: Modules were resolved with conflicting cross-version suffixes -