Re: gnome_config_set_vector()




Evan Martin <eeyem@u.washington.edu> writes:
> 	char *strings[] = { ... };
> 
> 	gnome_config_set_vector("/some/path", string_count, 
> 		(const char* const *)strings);
> 
> Am I misunderstanding the purpose of "vectors", in the gnome_config sense?
> 

The cast is required because C is too stupid to implicitly cast
"nested" non-const objects to const. That is, if you pass a char* to a
function that takes const char*, you get no warning, but if you pass a 
char** to a const char** function then you get warned.

The cast is unfortunate but inevitable, because there's no way to know
whether users will have a const char* const* or a const char** or a
char** or what. So some users will have to put in a cast no matter
what you do.

Havoc



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]