1 year, 3 months ago.

RawSerial.h class error

Hello I'm new with mbed os,

I'm trying to compile an existing project from Eclipse but I have the following error;

Console: RawSerial.h:56:35: error: expected class-name before ',' token

Rawserial.h include


#include "platform/platform.h"


#include "mbed_toolchain.h"
#include "drivers/SerialBase.h"
#include "hal/serial_api.h"
#include "platform/NonCopyable.h"

Raw serial class declaring

class RawSerial: public SerialBase, private NonCopyable<RawSerial> {
    int putc(int c);
    int getc();
    int puts(const char *str);
    int printf(const char *format, ...) MBED_PRINTF_METHOD(1, 2);
} // namespace mbed

It look like a redefinition error. I try to comment previous definitions one by one, but the error is still there. I can't understand the source of the error.

Edit 22-10-2019 :


Thank you for your help.

Regards Alexandre

1 Answer

1 year, 3 months ago.

Hello Alexandre,

It seems the SerialBase class name is not recognized by the compiler. Make sure the path to the SerialBase.h header file has been added to the INCLUDE_PATHS variable. The same applies also to the NonCopyable.h header file path.
Edit: Check the INCLUDE_PATHS variable in the project's Makefile. Could find lines like:


INCLUDE_PATHS += -I../mbed/drivers
INCLUDE_PATHS += -I../mbed/platform

Accepted Answer

Hello Zoltan, thank you for your response. I check the includes dependencies with "Eclipse include browser tool" and it looks like that SerialBase.h and NonCopyable.h are found (see print screen in the first post). But I noticed the code in serial base was inactive because of the directive: #if DEVICE_SERIAL || defined(DOXYGEN_ONLY).

So it’s like the serialbase.h was absent. So I add #define DEVICE_SERIAL 1 inside serialbase.h and I have no more class error.

It lead me to new question. How to know which mbed-os includes delclarations are necessaries?

Thanks you for your help.

Regards Alexandre

posted by Alexandre Mendy 22 Oct 2019