"Francois Gouget" <[EMAIL PROTECTED]> wrote: > We find the same issues with an added twist: now that we can use > literals we can write things like: > > const char* str = "String literal"; > > However this is slightly different from: > > static const char* str[] = "String literal"; > > The difference is that in the first case sizeof(str) returns 4 (on 32 > bit machines<g>) while in the latter we get 15. Some of our code relies > on this so care must be taken when converting the latter to the former.
My understanding of this is that in the first case you declare a const pointer and hope that a compiler is smart enough to place a pointed by it object into a read only section, while in the second case you explicitly say to a compiler to place the whole object into a read only section. I prefer to not rely on a compiler's good will. -- Dmitry.