ringbuffer: use a namespace for ringbuffer to avoid 'multiple definitions in vtable' bug

This commit is contained in:
Ban Siesta
2015-05-24 10:02:08 +01:00
parent b9ce447cc9
commit aac276872b
3 changed files with 14 additions and 10 deletions
+3 -2
View File
@@ -41,7 +41,8 @@ SRCS = \
cdev.cpp \
i2c_nuttx.cpp \
pio.cpp \
spi.cpp
spi.cpp \
ringbuffer.cpp
else
SRCS = \
device_posix.cpp \
@@ -50,5 +51,5 @@ SRCS = \
vdev_posix.cpp \
i2c_posix.cpp \
sim.cpp \
ringbuffer.cpp
ringbuffer.cpp
endif
+6 -1
View File
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (C) 2013 PX4 Development Team. All rights reserved.
* Copyright (C) 2013-2015 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -40,6 +40,9 @@
#include "ringbuffer.h"
#include <string.h>
namespace ringbuffer
{
RingBuffer::RingBuffer(unsigned num_items, size_t item_size) :
_num_items(num_items),
_item_size(item_size),
@@ -398,3 +401,5 @@ RingBuffer::print_info(const char *name)
_tail,
_buf);
}
} // namespace ringbuffer
+5 -7
View File
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (C) 2013 PX4 Development Team. All rights reserved.
* Copyright (C) 2013-2015 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -43,6 +43,9 @@
#include <stdint.h>
#include <stdio.h>
namespace ringbuffer __EXPORT
{
class RingBuffer {
public:
RingBuffer(unsigned ring_size, size_t entry_size);
@@ -172,9 +175,4 @@ private:
RingBuffer operator=(const RingBuffer&);
};
#ifdef __PX4_NUTTX
// Not sure why NuttX requires these to be defined in the header file
// but on other targets it causes a problem with multiple definitions
// at link time
#include "ringbuffer.cpp"
#endif
} // namespace ringbuffer