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 - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -