Please note that this is in a typedef. The initialization needs to happen when a structure of this type is declared.
const PragmaName g_mypragma = { "mypragma", ...}; Would allow the compiler to put *both* the string "mypragma" *and* the structure g_mypragma into (read only) "string space", with the linker/loader calculating the actual value of the pointer. -----Ursprüngliche Nachricht----- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Dominique Devienne Gesendet: Mittwoch, 02. Jänner 2019 14:22 An: SQLite mailing list <sqlite-users@mailinglists.sqlite.org> Betreff: [EXTERNAL] Re: [sqlite] A Minor Issue Report: Extra const Keyword in PragmaName zName On Wed, Jan 2, 2019 at 1:47 PM Richard Damon <rich...@damon-family.org> wrote: > On 12/30/18 6:10 PM, Richard Green wrote: > const char *const zName; // Note extra space > > Then that is declaring that zName is an immutable pointer to a > immutable string/character, which is actually likely true, as the code > shouldn't be changing the names of pragmas. > Yeah, but a const T*const pointer must be initialized. (unless it's a function argument, in which case it's the "caller" doing the init, somehow). Otherwise how else would you assign a value to that const pointer? So as-is as a struct field, it wouldn't make sense. C has no constructor like C++ has, to perform the assignment in the "initializer list" of the Ctor (i.e. between : and { ) (maybe aggregate initialization can, that's as close to a Ctor C has. May that would work...) In Java you can, it's called a "blank final", i.e. compiler tracks at compile-time when the variable is first assigned, allowing that one, and errors out at all other assignments (or if not initialized at all). But in C/C++, I logically don't see how that makes sense. Haven't tried it recently though :). --DD _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___________________________________________ Gunter Hick | Software Engineer | Scientific Games International GmbH | Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 1 80100 - 0 May be privileged. May be confidential. Please delete if not the addressee. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users