Discussion:
[Viking-devel] viktrwlayer.cpp: invalid conversion from gpointer {aka void*} to void**
Kamil Ignacak
2016-04-08 15:31:33 UTC
Permalink
Hi!

I hope that this is a good place to send such information to.

I'm in the process of porting Viking to C++, and during compilation of
src/viktrwlayer.cpp the compiler issued multiple errors about invalid
conversions. Most of them were easy to fix and shouldn't be a problem in
C program, but there are two classes of errors that I think are worth
looking at:

1. Invalid conversion from void* to void**:
viktrwlayer.cpp: In function ‘void waypoint_search_closest_tp(gpointer,
VikWaypoint*, WPSearchParams*)’:
viktrwlayer.cpp:9081:29: error: invalid conversion from ‘gpointer {aka
void*}’ to ‘void**’ [-fpermissive]
params->closest_wp_id = id;

2. Invalid conversion from void* to GtkWidget**
viktrwlayer.cpp:1378:45: error: invalid conversion from ‘gpointer {aka
void*}’ to ‘GtkWidget** {aka _GtkWidget**}’ [-fpermissive]
GtkWidget **ww2 = values[UI_CHG_LABELS];

There are ~45 such errors in viktrwlayer.cpp.

I think that these problems *might* be caused by declarations of some
struct fields and arguments of type "gpointer *", but I may be wrong.

I understand that currently Viking can be compiled and these g++ errors
don't cause any problems in Viking. I just thought that you may be
interested.

I'm not sure if it's ok to post here compilation log +1000 lines long,
so I have just given you two examples. You can reproduce full log for
viktrwlayer.cpp by editing the file name in src/Makefile.am,
regenerating build files and attempting to compile the program.

Best regards,
Kamil

------------------------------------------------------------------------------
Robert Norris
2016-04-09 13:28:02 UTC
Permalink
Date: Fri, 8 Apr 2016 17:31:33 +0200
Subject: [Viking-devel] viktrwlayer.cpp: invalid conversion from gpointer {aka void*} to void**
Hi!
I hope that this is a good place to send such information to.
I'm in the process of porting Viking to C++, and during compilation of
src/viktrwlayer.cpp the compiler issued multiple errors about invalid
conversions. Most of them were easy to fix and shouldn't be a problem in
C program, but there are two classes of errors that I think are worth
viktrwlayer.cpp: In function ‘void waypoint_search_closest_tp(gpointer,
viktrwlayer.cpp:9081:29: error: invalid conversion from ‘gpointer {aka
void*}’ to ‘void**’ [-fpermissive]
params->closest_wp_id = id;
There are several cases of using gpointer *variable; which were probably unintentional mistakes and should be simply just be gpointer variable;
I think I have fixed all the cases that are were doing the wrong thing but somehow the code still worked.
2. Invalid conversion from void* to GtkWidget**
viktrwlayer.cpp:1378:45: error: invalid conversion from ‘gpointer {aka
void*}’ to ‘GtkWidget** {aka _GtkWidget**}’ [-fpermissive]
GtkWidget **ww2 = values[UI_CHG_LABELS];
This is not an error as values[UI_CHG_LABELS] is a pointer array (and so is values[UI_CHG_WIDGETS]).

So simply confirming the type casting like this is OK:

GtkWidget **ww2 = (GtkWidget **)values[UI_CHG_LABELS];
I understand that currently Viking can be compiled and these g++ errors
don't cause any problems in Viking. I just thought that you may be
interested.
I'm not sure if it's ok to post here compilation log +1000 lines long,
so I have just given you two examples. You can reproduce full log for
viktrwlayer.cpp by editing the file name in src/Makefile.am,
regenerating build files and attempting to compile the program.
I simply changed the Makefile entry of CC=gcc to be CC=g++, but I then got bored of having to fix all the implicit type conversions that fail in C++, and moved viktrwlayer.c up so it would get compiled earlier.

Please report any more things that might be actual errors, rather than the C++ compiler being more strict on type conversions issues.
Best regards,
Kamil
------------------------------------------------------------------------------
_______________________________________________
Viking-devel mailing list
https://lists.sourceforge.net/lists/listinfo/viking-devel
Viking home page: http://viking.sf.net/
Kamil Ignacak
2016-04-09 20:00:56 UTC
Permalink
Post by Robert Norris
Please report any more things that might be actual errors, rather than the C++ compiler being more strict on type conversions issues.
The only other problems that I've noticed are in src/kmz.c:

1. call to g_strinfree() instead of g_string_free()
2. zip_int64_t_t data type instead of zip_int64_t

Since I'm done with converting files from *.c to *.cpp, I think that
this is the last report of this type.

Best regards,
Kamil
Kamil Ignacak
2016-04-09 21:04:16 UTC
Permalink
Please disregard the last message, the problem occurred only in my repo.
Sorry for spamming the list.

Best regards,
Kamil

Loading...