[hafqa] [hafqa] [Bug 3226] /usr/include/location/* headers need to be extern "C"

From: bugzilla-daemon at maemo.org bugzilla-daemon at maemo.org
Date: Fri Jun 6 01:25:48 EEST 2008
https://bugs.maemo.org/show_bug.cgi?id=3226





------- Comment #1 from doug.turner at gmail.com  2008-06-06 01:25 GMT+3 -------
when compiling a simple application:

#include <gtk/gtk.h>
#include <glib.h>
#include <errno.h>
#include <gpsbt.h>
#include <gpsmgr.h>
#include <location/location-gps-device.h>
#include <location/location-gpsd-control.h>

static void
location_changed (LocationGPSDevice *device, gpointer userdata)
{
   printf ("Latitude: %.5f\nLongitude: %.5f\nAltitude: %.2f\n",
         device->fix->latitude, device->fix->longitude, device->fix->altitude);
}

int main(int argc, char **argv)
{
  gtk_init (&argc, &argv);
  gpsbt_t ctx = {0};  /* clearing the context is important! */
  int st = gpsbt_start(NULL, 0, 0, 0, NULL, 0, 0, &ctx);
  printf("gpsmgr returned %d (%d)\n", st, errno);

  LocationGPSDevice *device;
  device = (LocationGPSDevice *) g_object_new (LOCATION_TYPE_GPS_DEVICE, NULL);
  g_signal_connect (device, "changed", G_CALLBACK (location_changed), NULL);

  gtk_main();
  gpsbt_stop(&ctx);
}

With this compile line:

c++ xx.cpp `pkg-config --libs --cflags gtk+-2.0`  -llocation

The result is:

/var/tmp/ccSd5pb7.o: In function `main':xx.cpp:(.text+0x150): undefined
reference to `location_gps_device_get_type()'
collect2: ld returned 1 exit status


If the file is a c file, and I use gcc, the program goes away.

What I ended up doing in my code is:

extern "C" {  
  #include <location/location-gps-device.h>
  #include <location/location-gpsd-control.h>
}

which seems to work just fine.

The real resolution should be to extern all function in the header files as
"C".


-- 
Configure bugmail: https://bugs.maemo.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.

More information about the hafqa mailing list