0
我用在线ARMCC编译器构建了一个mbed项目,它根本没有任何抱怨。将项目导出到脱机Keil MDK5后。我有下面的投诉。如果有人知道如何删除/更正此类问题,请咨询。带模板的CircularBuffer在Keil MDK5上模糊不清?
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);
我知道环形缓冲区似乎暧昧,如果有differenet类型,但环形缓冲区被定义为模板,应使用不同类型的?和在线编译器通过,但MDK5没有,是否有任何编译器选项应该启用?
该环形缓冲区中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
这个编译器是否支持模板? – VTT
尽管没有官方文档支持,但模板在其他项目中与Keil MDK5一起工作良好。所以,我想是的。 –
是的,我已经证实,模板由Keil MDK5支持,通过导出另一个[名为MyBuffer的基于模板的演示项目](https://developer.mbed.org/users/sam_grove/code/Buffer/)。有问题的项目称为[RingBuffer](https://developer.mbed.org/teams/ENEL400/code/RingBuffer/),其相关项目称为[LoRaBaseStation](https://developer.mbed.org/teams/ENEL400/code/LoRaBaseStation /)和[LoRaTerminal](https://developer.mbed.org/teams/ENEL400/code/LoRaTerminal/)。这两个项目都可以在线构建,但使用Keil MDK5失败。所以,在代码中出现错误。 –