mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 00:31:36 +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 \
|
cdev.cpp \
|
||||||
i2c_nuttx.cpp \
|
i2c_nuttx.cpp \
|
||||||
pio.cpp \
|
pio.cpp \
|
||||||
spi.cpp
|
spi.cpp \
|
||||||
|
ringbuffer.cpp
|
||||||
else
|
else
|
||||||
SRCS = \
|
SRCS = \
|
||||||
device_posix.cpp \
|
device_posix.cpp \
|
||||||
@@ -50,5 +51,5 @@ SRCS = \
|
|||||||
vdev_posix.cpp \
|
vdev_posix.cpp \
|
||||||
i2c_posix.cpp \
|
i2c_posix.cpp \
|
||||||
sim.cpp \
|
sim.cpp \
|
||||||
ringbuffer.cpp
|
ringbuffer.cpp
|
||||||
endif
|
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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -40,6 +40,9 @@
|
|||||||
#include "ringbuffer.h"
|
#include "ringbuffer.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
namespace ringbuffer
|
||||||
|
{
|
||||||
|
|
||||||
RingBuffer::RingBuffer(unsigned num_items, size_t item_size) :
|
RingBuffer::RingBuffer(unsigned num_items, size_t item_size) :
|
||||||
_num_items(num_items),
|
_num_items(num_items),
|
||||||
_item_size(item_size),
|
_item_size(item_size),
|
||||||
@@ -398,3 +401,5 @@ RingBuffer::print_info(const char *name)
|
|||||||
_tail,
|
_tail,
|
||||||
_buf);
|
_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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -43,6 +43,9 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
namespace ringbuffer __EXPORT
|
||||||
|
{
|
||||||
|
|
||||||
class RingBuffer {
|
class RingBuffer {
|
||||||
public:
|
public:
|
||||||
RingBuffer(unsigned ring_size, size_t entry_size);
|
RingBuffer(unsigned ring_size, size_t entry_size);
|
||||||
@@ -172,9 +175,4 @@ private:
|
|||||||
RingBuffer operator=(const RingBuffer&);
|
RingBuffer operator=(const RingBuffer&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __PX4_NUTTX
|
} // namespace ringbuffer
|
||||||
// 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
|
|
||||||
|
|||||||
Reference in New Issue
Block a user