定义一个结构体</strong>
431typedef struct {
432 /** set to sizeof(GpsLocation) */
433 size_t size;
434 /** Contains GpsLocationFlags bits. */
435 uint16_t flags;
436 /** Represents latitude in degrees. */
437 double latitude;
438 /** Represents longitude in degrees. */
439 double longitude;
440 /** Represents altitude in meters above the WGS 84 reference
441 * ellipsoid. */
442 double altitude;
443 /** Represents speed in meters per second. */
444 float speed;
445 /** Represents heading in degrees. */
446 float bearing;
447 /** Represents expected accuracy in meters. */
448 float accuracy;
449 /** Timestamp for the location fix. */
450 GpsUtcTime timestamp;
451}<strong> GpsLocation</strong>;
452
函数验证仿造 <span style="background-color: rgb(255, 255, 0);">typedef struct{ //定义一个结构体
int age;
int num;
}GpsLocation;</span>
</pre><pre code_snippet_id="1744873" snippet_file_name="blog_20160704_5_7527996" name="code" class="cpp" style="background-color: rgb(255, 255, 255);"><strong>二 ,定义回调函数</strong>
/** Callback with location information.
527 * Can only be called from a thread created by create_thread_cb.
528 */
529typedef void (* gps_location_callback)(GpsLocation
530
531/** Callback with status information.
532 * Can only be called from a thread created by create_thread_cb.
533 */
534typedef void (* gps_status_callback)(GpsStatus* status);</span>
三,call back的结构体函数
typedef struct {
gps_location_callback location_cb; //定义函数指针变量
}GpsCallbacks;
/** GPS callback structure. */
569typedef struct {
570 /** set to sizeof(GpsCallbacks) */
571 size_t size;
572 gps_location_callback location_cb;
573 gps_status_callback status_cb;
574 gps_sv_status_callback sv_status_cb;
575 gps_nmea_callback nmea_cb;
576 gps_set_capabilities set_capabilities_cb;
577 gps_acquire_wakelock acquire_wakelock_cb;
578 gps_release_wakelock release_wakelock_cb;
579 gps_create_thread create_thread_cb;
580 gps_request_utc_time request_utc_time_cb;
581} GpsCallbacks;