Skip to content

Commit

Permalink
Fix examples so they build on gcc 4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
mfontanini committed Feb 21, 2016
1 parent fa4178d commit 8bf0c35
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
17 changes: 10 additions & 7 deletions examples/dns_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#define NOMINMAX
#endif // _WIN32

// Fix for gcc 4.6
#define _GLIBCXX_USE_NANOSLEEP

#include <iostream>
#include <mutex>
#include <chrono>
Expand Down Expand Up @@ -65,8 +68,8 @@ using namespace Tins;
template<typename Duration>
class statistics {
public:
using duration_type = Duration;
using locker_type = lock_guard<mutex>;
typedef Duration duration_type;
typedef lock_guard<mutex> locker_type;

struct information {
duration_type average, worst;
Expand Down Expand Up @@ -108,18 +111,18 @@ class statistics {
class dns_monitor {
public:
// The response times are measured in milliseconds
using duration_type = milliseconds;
typedef milliseconds duration_type;
// The statistics type used.
using statistics_type = statistics<duration_type>;
typedef statistics<duration_type> statistics_type;

void run(BaseSniffer& sniffer);
const statistics_type& stats() const {
return m_stats;
}
private:
using packet_info = tuple<IPv4Address, IPv4Address, uint16_t>;
using clock_type = system_clock;
using time_point_type = clock_type::time_point;
typedef tuple<IPv4Address, IPv4Address, uint16_t> packet_info;
typedef system_clock clock_type;
typedef clock_type::time_point time_point_type;

bool callback(const PDU& pdu);
static packet_info make_packet_info(const PDU& pdu, const DNS& dns);
Expand Down
5 changes: 4 additions & 1 deletion examples/traceroute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#define NOMINMAX
#endif // _WIN32

// Fix for gcc 4.6
#define _GLIBCXX_USE_NANOSLEEP

#include <iostream>
#include <chrono>
#include <thread>
Expand Down Expand Up @@ -128,7 +131,7 @@ class Traceroute {
}

sender.send(ip);
// Give him a little time
// Give it a little time
sleep_for(milliseconds(100));
}
running = false;
Expand Down

0 comments on commit 8bf0c35

Please sign in to comment.