guchar -> gchar?

View: New views
7 Messages — Rating Filter:   Alert me  

guchar -> gchar?

by Lutz Mueller-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello!

Latest gcc produces lots of warnings like:

gnome-print.c:738: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness

the reason being gcc complaining about using unsigned char for standard strings instead of char.

Would it generate any problems elsewhere (compatiblity?) if we just
changed the API from guchar* to gchar* for standard strings in a couple
of places (namely gnome-print.h and gnome-print-config.h)?

Regards
--
Lutz Müller <lutz@...>

_______________________________________________
gnome-print-list mailing list
gnome-print-list@...
http://mail.gnome.org/mailman/listinfo/gnome-print-list

Re: guchar -> gchar?

by Andreas J. Guelzow :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 2005-03-08 at 00:01 +0200, Lutz Müller wrote:

> Hello!
>
> Latest gcc produces lots of warnings like:
>
> gnome-print.c:738: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness
>
> the reason being gcc complaining about using unsigned char for standard strings instead of char.
>
> Would it generate any problems elsewhere (compatiblity?) if we just
> changed the API from guchar* to gchar* for standard strings in a couple
> of places (namely gnome-print.h and gnome-print-config.h)?
It will likely cause lots of warning messages in existing code using
guchar* to call those functions! Note that the real cause of the
warnings that you see is _not_ that those functions expect guchar* but
that you (or whoever wrote the code) is passing to them gchar*.

Andreas
--
Prof. Dr. Andreas J. Guelzow
Dept. of Mathematical & Computing Sciences
Concordia University College of Alberta


_______________________________________________
gnome-print-list mailing list
gnome-print-list@...
http://mail.gnome.org/mailman/listinfo/gnome-print-list

signature.asc (196 bytes) Download Attachment

Re: guchar -> gchar?

by Lutz Mueller-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 2005-08-02 at 18:04 -0600, Andreas J. Guelzow wrote:
> It will likely cause lots of warning messages in existing code using
> guchar* to call those functions! Note that the real cause of the
> warnings that you see is _not_ that those functions expect guchar* but
> that you (or whoever wrote the code) is passing to them gchar*.

strlen, strdup, strcpy all use char. The convention seems to use char
for all (user readable) strings. I don't see added value for
- casting strings to unsigned char when passing them to libgnomeprint
- casting them to char within libgnomeprint
- casting them to unsigned char when returning them
- casting them to char for further use in the calling function.

On Tue, 2005-08-02 at 19:25 -0300, John Coppens wrote:
> Won't you have problems with upper-128 characters like é, í, ü etc?

We're using UTF-8.

--
Lutz Müller <lutz@...>

_______________________________________________
gnome-print-list mailing list
gnome-print-list@...
http://mail.gnome.org/mailman/listinfo/gnome-print-list

Re: guchar -> gchar?

by Andreas J. Guelzow :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 2005-03-08 at 08:02 +0200, Lutz Müller wrote:

> On Tue, 2005-08-02 at 18:04 -0600, Andreas J. Guelzow wrote:
> > It will likely cause lots of warning messages in existing code using
> > guchar* to call those functions! Note that the real cause of the
> > warnings that you see is _not_ that those functions expect guchar* but
> > that you (or whoever wrote the code) is passing to them gchar*.
>
> strlen, strdup, strcpy all use char. The convention seems to use char
> for all (user readable) strings. I don't see added value for
> - casting strings to unsigned char when passing them to libgnomeprint
> - casting them to char within libgnomeprint
> - casting them to unsigned char when returning them
> - casting them to char for further use in the calling function.
This may have been an argument to use gchar* when gnomeprint was first
written, but you are arguing to _changge_ the types and to create
warnings for a large body of code that so far has coretly used that API.

I do not think that this is sufficient reason to break the API.

Andreas

--
Andreas J. Guelzow
Taliesin Software, Shelties, Pyr Sheps
and Shetland Sheep


_______________________________________________
gnome-print-list mailing list
gnome-print-list@...
http://mail.gnome.org/mailman/listinfo/gnome-print-list

signature.asc (196 bytes) Download Attachment

Re: guchar -> gchar?

by Lutz Mueller-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 2005-08-03 at 00:14 -0600, Andreas J. Guelzow wrote:
> I do not think that this is sufficient reason to break the API.

This is exactly what I was asking: Would the change from guchar to gchar
"break the API"? As far as I understand, binary compatibility would not
be broken (same size).

If the change isn't worth it, may I add "(const guchar *)" to
libgnomeprint (i.e.

drivername = gnome_print_config_get (config,
  (const guchar *) "Settings.Engine.Backend.Driver");

) to libgnomeprint to get rid of the warnings?

Regards
--
Lutz Müller <lutz@...>

_______________________________________________
gnome-print-list mailing list
gnome-print-list@...
http://mail.gnome.org/mailman/listinfo/gnome-print-list

Re: guchar -> gchar?

by Andreas J. Guelzow :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 2005-03-08 at 08:50 +0200, Lutz Müller wrote:
> If the change isn't worth it, may I add "(const guchar *)" to
> libgnomeprint (i.e.
>
> drivername = gnome_print_config_get (config,
>   (const guchar *) "Settings.Engine.Backend.Driver");
>
> ) to libgnomeprint to get rid of the warnings?

I do not see anything wrong with you using these casts in your code to
avoid the warning messages.

Just out of curiosity, what compiler are you using? I do not seem to get
those warnings with
gcc -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations
-Wpointer-arith ...

Andreas
--
Andreas J. Guelzow
Taliesin Software, Shelties, Pyr Sheps
and Shetland Sheep


_______________________________________________
gnome-print-list mailing list
gnome-print-list@...
http://mail.gnome.org/mailman/listinfo/gnome-print-list

signature.asc (196 bytes) Download Attachment

Re: guchar -> gchar?

by Jody Goldberg-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Aug 03, 2005 at 08:50:30AM +0200, Lutz M?ller wrote:

> On Wed, 2005-08-03 at 00:14 -0600, Andreas J. Guelzow wrote:
> > I do not think that this is sufficient reason to break the API.
>
> This is exactly what I was asking: Would the change from guchar to gchar
> "break the API"? As far as I understand, binary compatibility would not
> be broken (same size).
>
> If the change isn't worth it, may I add "(const guchar *)" to
> libgnomeprint (i.e.
>
> drivername = gnome_print_config_get (config,
>   (const guchar *) "Settings.Engine.Backend.Driver");
>
> ) to libgnomeprint to get rid of the warnings?

This seems like compiler foolishness.  The casts and a change to the
types in the api (even though it does not break bin compat) seem
pointless.  Let's just disable the warning.
_______________________________________________
gnome-print-list mailing list
gnome-print-list@...
http://mail.gnome.org/mailman/listinfo/gnome-print-list