mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
* HACKING: added explanation for const_cast.
This commit is contained in:
parent
d5f70f2ab8
commit
5418fdc3a8
@ -1,3 +1,7 @@
|
||||
2004-09-19 Roland Illig <roland.illig@gmx.de>
|
||||
|
||||
* HACKING: added explanation for const_cast.
|
||||
|
||||
2004-09-17 Dmitry Alexeyev <dmi_a@qnx.org.ru>
|
||||
|
||||
* syntax/makefile.syntax.diff: adds define and ended keyrowrds
|
||||
|
10
HACKING
10
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.
|
||||
|
Loading…
Reference in New Issue
Block a user