Skip to content

Commit

Permalink
Fixes some issues with C++11.
Browse files Browse the repository at this point in the history
In compiler.h, it adds the missing "std::" namespace prefixes to the
memory_barrier() definition.

In gpsd.h it:

1) Moves the include of compiler.h outside the conditional 'extern
"C"', since the "atomic" stuff in the former is incompatible with the
latter.

2) Fixes DEVICEHOOKPATH for C++11 (C++11 requires spaces between
literals and string macros).

3) Cleans up some ordering of system includes left over from the
former head/tail setup.

TESTED:
Ran "scons build-all check" on OSX 10.5-10.12, Ubuntu 14, CentOS 7,
Fedora 25, FreeBSD 10.3, OpenBSD 5.6 (32- and 64-bit), and NetBSD
6.1.5.  Also tested Qt builds with OSX 10.9 (Qt4 and Qt5), OSX 10.12
(Qt5), and Fedora 25 (Qt5).
Observed the correct DEVICEHOOKPATH in the log on OSX.
  • Loading branch information
fhgwright committed Jan 25, 2017
1 parent 744959a commit d287c76
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static inline void memory_barrier(void)
/* we are C++ */
#if __cplusplus >= 201103L
/* C++11 and later has atomics, earlier do not */
atomic_thread_fence(memory_order_seq_cst);
std::atomic_thread_fence(std::memory_order_seq_cst);
#endif
#elif defined HAVE_STDATOMIC_H
/* we are C and atomics are in C98 and newer */
Expand Down
15 changes: 7 additions & 8 deletions gpsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,21 @@
#ifndef _GPSD_H_
#define _GPSD_H_

#include "compiler.h" /* Must be outside extern "C" for "atomic" */

# ifdef __cplusplus
extern "C" {
# endif

#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <time.h> /* for time_t */

#include "gpsd_config.h"

#include <stdint.h>
#include <stdarg.h>
#include <stdio.h>
#include <termios.h>
#include <time.h> /* for time_t */

#include "gps.h"
#include "compiler.h"
#include "gpsd_config.h"
#include "os_compat.h"

/*
Expand Down Expand Up @@ -991,7 +990,7 @@ PRINTF_FUNC(3, 4) void gpsd_log(const struct gpsd_errout_t *, const int, const c
void cfmakeraw(struct termios *);
#endif /* defined(__CYGWIN__) */

#define DEVICEHOOKPATH "/"SYSCONFDIR"/gpsd/device-hook"
#define DEVICEHOOKPATH "/" SYSCONFDIR "/gpsd/device-hook"

# ifdef __cplusplus
}
Expand Down

0 comments on commit d287c76

Please sign in to comment.