带有模板的 CircularBuffer 在 Keil MDK5 上是模棱两可的错误?
CircularBuffer with template is ambiguous error on Keil MDK5?
我用在线ARMCC编译器构建了一个mbed项目,完全没有抱怨。导出项目到离线Keil MDK5后。我收到了以下投诉。请有知道的人指点一下remove/correct这样的问题
SerialInterfaceProtocol/SerialInterfaceProtocol.h(16): error: #266: "CircularBuffer" is ambiguous
typedef CircularBuffer<uint8_t> SerialBuffer_t;
AlohaTransceiver/AlohaTransceiver.h(178): error: #266: "CircularBuffer" is ambiguous
CircularBuffer<AlohaFrame *> AlohaTxQueue;
AlohaTransceiver/AlohaTransceiver.cpp(44): error: #266: "CircularBuffer" is ambiguous
CircularBuffer<AlohaFrame *> AlohaRxQueue(10);
main.cpp(12): error: #266: "CircularBuffer" is ambiguous
CircularBuffer<uint8_t> SerialInputBuffer(128);
main.cpp(13): error: #266: "CircularBuffer" is ambiguous
CircularBuffer<uint8_t> SerialOutputBuffer(128);
我知道CircularBuffer如果有不同的类型看起来会模棱两可,但是CircularBuffer被定义为一个模板,它应该用于不同的类型?并且在线编译通过了,但是MDK5没有通过,请问有什么编译选项需要开启吗?
CircularBuffer 定义在RingBuffer.h
#ifndef RINGBUFFER_H_
#define RINGBUFFER_H_
#define DEFAULT_MAX_BUFFER_SZ 64
#include <stdint.h>
#include <stdlib.h>
template <typename T>
class CircularBuffer
{
private:
const size_t buffer_size;
size_t read_ptr;
size_t write_ptr;
size_t count;
// mutex lock
bool mux;
// overflow
bool is_over_flow;
// container
T *data;
public:
CircularBuffer(const size_t size=DEFAULT_MAX_BUFFER_SZ);
~CircularBuffer();
// psudo mutex
bool isLocked();
void lock();
void unlock();
// enqueue and dequeue
void enqueue(T in);
T dequeue();
// pointer operation
size_t getReadPtr();
size_t getWritePtr();
size_t getCounter();
// overflow
bool getOverFlow();
void clearOverFlow();
// operation
T first();
T last();
// random access
T operator[](size_t idx);
};
#endif
项目中有两个CircularBuffer,一个在mbed OS,一个在用户代码中。合并它们,或重命名其中之一。
我用在线ARMCC编译器构建了一个mbed项目,完全没有抱怨。导出项目到离线Keil MDK5后。我收到了以下投诉。请有知道的人指点一下remove/correct这样的问题
SerialInterfaceProtocol/SerialInterfaceProtocol.h(16): error: #266: "CircularBuffer" is ambiguous
typedef CircularBuffer<uint8_t> SerialBuffer_t;
AlohaTransceiver/AlohaTransceiver.h(178): error: #266: "CircularBuffer" is ambiguous
CircularBuffer<AlohaFrame *> AlohaTxQueue;
AlohaTransceiver/AlohaTransceiver.cpp(44): error: #266: "CircularBuffer" is ambiguous
CircularBuffer<AlohaFrame *> AlohaRxQueue(10);
main.cpp(12): error: #266: "CircularBuffer" is ambiguous
CircularBuffer<uint8_t> SerialInputBuffer(128);
main.cpp(13): error: #266: "CircularBuffer" is ambiguous
CircularBuffer<uint8_t> SerialOutputBuffer(128);
我知道CircularBuffer如果有不同的类型看起来会模棱两可,但是CircularBuffer被定义为一个模板,它应该用于不同的类型?并且在线编译通过了,但是MDK5没有通过,请问有什么编译选项需要开启吗?
CircularBuffer 定义在RingBuffer.h
#ifndef RINGBUFFER_H_
#define RINGBUFFER_H_
#define DEFAULT_MAX_BUFFER_SZ 64
#include <stdint.h>
#include <stdlib.h>
template <typename T>
class CircularBuffer
{
private:
const size_t buffer_size;
size_t read_ptr;
size_t write_ptr;
size_t count;
// mutex lock
bool mux;
// overflow
bool is_over_flow;
// container
T *data;
public:
CircularBuffer(const size_t size=DEFAULT_MAX_BUFFER_SZ);
~CircularBuffer();
// psudo mutex
bool isLocked();
void lock();
void unlock();
// enqueue and dequeue
void enqueue(T in);
T dequeue();
// pointer operation
size_t getReadPtr();
size_t getWritePtr();
size_t getCounter();
// overflow
bool getOverFlow();
void clearOverFlow();
// operation
T first();
T last();
// random access
T operator[](size_t idx);
};
#endif
项目中有两个CircularBuffer,一个在mbed OS,一个在用户代码中。合并它们,或重命名其中之一。