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

Re: [E-devel] E CVS: proto essiene



Enlightenment CVS wrote:
Enlightenment CVS committal

Author  : essiene
Project : e17
Module  : proto

Dir     : e17/proto/entrance_edit_gui/src/widgets


Modified Files:
ew_entry.c ew_entry.h

Log Message:
- Fix return type warning when getting an etk_entry, it returns a const char*, but we use normal char*'s everywhere.

===================================================================
RCS file: /cvs/e/e17/proto/entrance_edit_gui/src/widgets/ew_entry.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ew_entry.c	16 Aug 2006 12:52:01 -0000	1.7
+++ ew_entry.c	16 Aug 2006 13:13:30 -0000	1.8
@@ -47,10 +47,10 @@
 	return ew;
 }
-const char*
+char*
 ew_entry_get(Entrance_Entry ew)
 {
-	return etk_entry_text_get(ETK_ENTRY(ew->control));
+	return (char*) etk_entry_text_get(ETK_ENTRY(ew->control));
 }
...

You should never (have to) cast away the const modifier. It is there for a purpose. It tells you (and the compiler) that here is a pointer to a piece of memory that you are not supposed to modify.

The compiler warns you if you pass a const pointer to a function that takes non-const pointer arguments, that you may be changing something you are not supposed to change. The compiler can also use the const modifier to make certain assumptions used for optimization, e.g. that the content of an object is unchanged across calling a function which takes a const pointer to the object.

If you seem to have to cast away a const pointer to avoid compiler warnings it is most likely because something is wrong somewhere.

/Kim