Static variables are not shared between processes. Each process gets its own data segment, which is where variables are placed. It doesn't matter whether they're const
or not.
About the const_cast
, you seem to be confused about what it's actually there for. It is able to remove the const
attribute from any variable. The whole point of it is to get the compiler to allow writing to a const
variable. You can use it on anything, and you do so at your own risk. If you strip the const
from something that really isn't writable, you're into undefined behavior.
A const static
variable has the usual meaning. It's static, and it's constant. The type doesn't matter; const static int
or const static A
. Means the same thing for both.
If you want to share the object between processes, then you will need to put it into POSIX shared memory and synchronize access to it. You use shm_open() for this. There are some tutorials on shared memory online, like this one for example.