Skip to content

Cannot generate typeinfo for HardwareSerial without at least one method default defined #845

Open
@mathemaphysics

Description

@mathemaphysics

Is your feature request related to a problem? Please describe.
Yes. In order to generate typeinfo for the HardwareSerial class (even with -frtti enabled), there must be a default empty definition somewhere of the HardwareSerial::begin(unsigned int) method (at least). I chose this one arbitrarily. Without these typeinfo symbols I can't dynamic_cast anything involving HardwareSerial.

Describe the solution you'd like
Add a HardwareSerial.cpp file with an empty definition of the previously mentioned begin method. Unfortunately the compiler won't take the hint from HardwareSerial.h in which

class HardwareSerial : public Stream
{
  public:
    virtual void begin(unsigned long);

};

becomes

class HardwareSerial : public Stream
{
  public:
    virtual void begin(unsigned long baudrate) {} // Now it's defined
};

because this is "inline" and apparently doesn't qualify as a sufficient indicator to allow RTTI to generate the typeinfo.

Describe alternatives you've considered
I've simply added my explicit default definition of HardwareSerial::begin(unsigned int) in another source file. This works, but it feels like this should be a part of the library because it serves as an abstract class.

Additional context
This issue isn't terribly important, but I will say that the ESP32 and ItsyBitsyM4 frameworks don't run into this problem at all. And it's an easy fix.

I can also submit the fix myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions