diff --git a/README.md b/README.md index af4a890..14fb1f5 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ systems. * No floating point usage in the core library. * Supports both fixed and floating point values. * One source file and one header - can't get any simpler. +* Tested under Linux, OS X, Windows and embedded ARM GCC. * Easily extendable to support new sentences. * Complete with a test suite and static analysis. @@ -29,6 +30,14 @@ systems. Adding support for more sentences is trivial; see ``minmea.c`` source. Good documentation on NMEA is at http://www.catb.org/gpsd/NMEA.html +## Compatibility + +Minmea runs out-of-the-box under most Unix-compatible systems. Support for non-Unix systems +(including native Windows builds under MSVC) is provided via compatibility headers: + +1. Define `MINMEA_INCLUDE_COMPAT` in the build environment. +2. Add appropriate compatibility header from under `compat/` directory as `minmea_compat.h`. + ## Fractional number format Internally, minmea stores fractional numbers as pairs of two integers: ``{value, scale}``. @@ -131,8 +140,7 @@ typing ``make``. (or equivalent) to remove the unused functions (parsers) from the final image. * Some systems lack ``timegm``. On these systems, the recommended course of action is to build with ``-Dtimegm=mktime`` which will work correctly as long - the system runs in the default ``UTC`` timezone. Native Windows builds should - use ``-Dtimegm=_mkgmtime`` instead which will work correctly in all timezones. + the system runs in the default ``UTC`` timezone. ## Bugs diff --git a/compat/minmea_compat_windows.h b/compat/minmea_compat_windows.h new file mode 100644 index 0000000..ef1ccb7 --- /dev/null +++ b/compat/minmea_compat_windows.h @@ -0,0 +1,23 @@ +/* + * Copyright © 2017 Kosma Moczek + * This program is free software. It comes without any warranty, to the extent + * permitted by applicable law. You can redistribute it and/or modify it under + * 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. + */ + +#if defined(_MSC_VER) + +#if !defined(HAVE_STRUCT_TIMESPEC) +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +#endif + +#define inline __inline +#define timegm _mkgmtime + +#endif + +/* vim: set ts=4 sw=4 et: */ diff --git a/minmea.h b/minmea.h index 10351f6..b80124c 100644 --- a/minmea.h +++ b/minmea.h @@ -19,6 +19,9 @@ extern "C" { #include #include #include +#ifdef MINMEA_INCLUDE_COMPAT +#include +#endif #define MINMEA_MAX_LENGTH 80