diff --git a/ChangeLog b/ChangeLog index 50930ae80..77e5b4dac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-09-19 Roland Illig + + * HACKING: added explanation for const_cast. + 2004-09-17 Dmitry Alexeyev * syntax/makefile.syntax.diff: adds define and ended keyrowrds diff --git a/HACKING b/HACKING index a2d31da85..3bc082d2d 100644 --- a/HACKING +++ b/HACKING @@ -280,12 +280,22 @@ user callback in some widgets. PROGRAMMING TIPS ================ +(This list should be sorted alphabetically.) + const: For every function taking a string argument, decide whether you (as a user of the function) would expect that the string is modi- fied by the function. If not, declare the string argument as "const char *". If your implementation needs to modify the string, use g_strdup to create a local copy. +const_cast: We use many libraries that do not know about "const char *" and + thus declare their functions to require "char *". In cases where we + know the function does not modify the string, we can use the macro + const_cast(char *, string_var) instead of a simple (char *) string_var + to make the intent clear. In cases where we are not sure what the + function does with the string, we should use g_strdup to pass + dynamically allocated strings. + g_strlcpy: Whenever you use this function, be sure to add "glibcompat.h" to the included headers. This is because in glib-1.2 there is no such function.