Posted to tcl by kbk at Thu Apr 26 21:38:23 GMT 2012view raw
- extern "C" {
- typedef struct KeyValue {
- char* key;
- int value;
- } KeyValue;
- }
- static const KeyValue pairs[] = {
- { "fred", 0 },
- { "barney", 1 }
- };
- const KeyValue* getPairs() {
- return pairs;
- }
- example.cpp:10:1: warning: deprecated conversion from string constant to char* [-Wwrite-strings]
- example.cpp:10:1: warning: deprecated conversion from string constant to char* [-Wwrite-strings]
Comments
Posted by jenglish at Fri Apr 27 01:24:25 GMT 2012 [text] [code]
Change the declaration to: struct KeyValue { const char *key; // <== note addition of const int value; }; and the initializer should work.