When I compile in and64 platform:
I can’t seem to figure it out. Here’s one of the lines it has trouble with:
static gboolean scan_freq(gpointer data)
{
static gint start, mom, max;
gint dir = (gint)(data); /// <- cast to pointer from integer of different size
if (!max) {
max = (FREQ_MAX - FREQ_MIN) * STEPS;
}
if (radio_check_station(gtk_adjustment_get_value(adj)/STEPS) || (start > max)) {
start = mom = 0;
radio_unmute();
timeout_id = 0;
return FALSE;
}
if (!mom) {
mom = gtk_adjustment_get_value(adj);
}
if (mom > FREQ_MAX*STEPS)
mom = FREQ_MIN*STEPS;
else if (mom < FREQ_MIN*STEPS)
mom = FREQ_MAX*STEPS;
else
mom = mom + dir;
start += 1;
gtk_adjustment_set_value(adj, mom);
return TRUE;
}
And:
extern int mom_ps;
void preset_menuitem_activate_cb(GtkMenuItem *menuitem, gpointer user_data)
{
preset* ps;
mom_ps = (int)user_data; /// <- cast to pointer from integer of different size
g_assert(mom_ps >= 0 && mom_ps < g_list_length(settings.presets));
ps = (preset*)g_list_nth_data(settings.presets, mom_ps);
gtk_adjustment_set_value(adj, ps->freq * STEPS);
}
Getting: cast to pointer from integer of different size warning
It’s actually a confusing error message since you seem to be casting away from a pointer.
However, the error is basically complaining that the types are not compatible.
Assuming that you’ve actually passed an integer as a pointer (Gnome specifically forbids trying to store pointers in an integer type), you should probably be using the actual type conversion macros like
GPOINTER_TO_INT?If instead, that pointer is a pointer to an integer, you should be deferencing it rather than casting it, something like:
The fact that it only happens on AMD64 is because that’s the sort of platform where pointers and integers would be a different size, one 64-bit, the other 32-bit.