Static assert for TX queue entry size

This commit is contained in:
Pavel Kirienko 2014-02-03 14:41:27 +04:00
parent 366ae6397e
commit 9559a9506a
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,30 @@
/*
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#include <cassert>
namespace uavcan
{
/**
* Usage:
* StaticAssert<expression>::check();
*/
template <bool VALUE>
struct StaticAssert
{
#if __CDT_PARSER__
static void check() { assert(0); }
#endif
};
template <>
struct StaticAssert<true>
{
static void check() { }
};
}

View File

@ -9,6 +9,7 @@
#include <stdint.h>
#include <uavcan/internal/linked_list.hpp>
#include <uavcan/internal/dynamic_memory.hpp>
#include <uavcan/internal/static_assert.hpp>
#include <uavcan/can_driver.hpp>
#include <uavcan/system_clock.hpp>
@ -45,6 +46,7 @@ public:
, qos(uint8_t(qos))
{
assert(qos == VOLATILE || qos == PERSISTENT);
StaticAssert<sizeof(Entry) <= 32>::check();
}
bool isExpired(uint64_t monotonic_timestamp) const { return monotonic_timestamp > monotonic_deadline; }