Преглед на файлове

Merge pull request #4 from mek-x/fix_gcc

Fixing compilation and tests for GCC on Linux
Kosma Moczek преди 11 години
родител
ревизия
b5b080cdaf
променени са 3 файла, в които са добавени 9 реда и са изтрити 5 реда
  1. 1 1
      Makefile
  2. 2 0
      minmea.h
  3. 6 4
      tests.c

+ 1 - 1
Makefile

@@ -4,7 +4,7 @@
 # the terms of the Do What The Fuck You Want To Public License, Version 2, as
 # published by Sam Hocevar. See the COPYING file for more details.
 
-CFLAGS = -g -Wall -Wextra -Werror
+CFLAGS = -g -Wall -Wextra -Werror -std=c99
 LDFLAGS = -lcheck
 
 all: scan-build test example

+ 2 - 0
minmea.h

@@ -9,6 +9,8 @@
 #ifndef MINMEA_H
 #define MINMEA_H
 
+#define _BSD_SOURCE
+
 #ifdef __cplusplus
 extern "C" {
 #endif

+ 6 - 4
tests.c

@@ -6,6 +6,8 @@
  * published by Sam Hocevar. See the COPYING file for more details.
  */
 
+#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
@@ -353,7 +355,7 @@ START_TEST(test_minmea_parse_rmc1)
 {
     const char *sentence = "$GPRMC,081836.75,A,3751.65,S,14507.36,E,000.0,360.0,130998,011.3,E";
     struct minmea_sentence_rmc frame = {};
-    struct minmea_sentence_rmc expected = {
+    static const struct minmea_sentence_rmc expected = {
         .time = { 8, 18, 36, 750000 },
         .valid = true,
         .latitude = -375165,
@@ -378,7 +380,7 @@ START_TEST(test_minmea_parse_rmc2)
 {
     const char *sentence = "$GPRMC,,A,3751.65,N,14507.36,W,,,,,";
     struct minmea_sentence_rmc frame = {};
-    struct minmea_sentence_rmc expected = {
+    static const struct minmea_sentence_rmc expected = {
         .time = { -1, -1, -1, -1 },
         .valid = true,
         .latitude = 375165,
@@ -397,7 +399,7 @@ START_TEST(test_minmea_parse_gga1)
 {
     const char *sentence = "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47";
     struct minmea_sentence_gga frame = {};
-    struct minmea_sentence_gga expected = {
+    static const struct minmea_sentence_gga expected = {
         .time = { 12, 35, 19, 0 },
         .latitude = 4807038,
         .latitude_scale = 1000,
@@ -425,7 +427,7 @@ START_TEST(test_minmea_parse_gsa1)
 {
     const char *sentence = "$GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39";
     struct minmea_sentence_gsa frame = {};
-    struct minmea_sentence_gsa expected = {
+    static const struct minmea_sentence_gsa expected = {
         .mode = MINMEA_GPGSA_MODE_AUTO,
         .fix_type = MINMEA_GPGSA_FIX_3D,
         .sats = { 4, 5, 0, 9, 12, 0, 0, 24, 0, 0, 0, 0 },