mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-16 23:47:34 +08:00
ringbuffer: use a namespace for ringbuffer to avoid 'multiple definitions in vtable' bug
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user