ajstarks / openvg

Tools for exploring OpenVG
Other
413 stars 84 forks source link

can char * be changed to const char * in shapes.h #47

Closed steverpi closed 8 years ago

steverpi commented 8 years ago

Is it possible to change the char * to const char * in shapes.h. The reason is:

  1. When you compile (with all warnings enabled) such as : Text(100, 100, "Hello World", MonoTypeface, 32) ;

you get a warning ... warning: passing argument 3 of ‘Text’ discards ‘const’ qualifier from pointer target type Text(100, 100, "Hello World", MonoTypeface, 32) ;

When there are 100s of such text prompts, I find it really hard to keep looking through all the warnings trying to decide which to ignore and would find it easier to not have such warnings so that I do not miss a 'real' warning.

  1. I use const char * for strings, which also gives the above warning. The reason I use them for strings is because when using multi-dimension prompts/strings, I need to use multi-dim arrays of pointers to the actual string, because they occupy a lot less space than multi-dim array of chars (because, the latter multi-dim array of chars needs to allocate space for the largest string throughout the array and so wastes space, whereas a multi-dim array of pointers does not.) For example, I use const char * for strings for multi language menu prompts and an example of an array I use is:

in the source int8_t * testStr[2][2] = { {"A long string of characters","just a few"}, {"Hello", "Another long prompt for displaying"} };

and In the header extern int8_t * testStr[2][2] ;

Thanks Steve

ajstarks commented 8 years ago

fixed with revision e8f4b6d