Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial::available() not const #76

Open
xico42 opened this issue Sep 3, 2014 · 2 comments
Open

Serial::available() not const #76

xico42 opened this issue Sep 3, 2014 · 2 comments

Comments

@xico42
Copy link

xico42 commented Sep 3, 2014

Is there any reason for Serial::available() method not being defined as const?

when in do this:

    class SerialTransport
    {
         public:
            ...
            size_t bytesAvailable() const;
            ...
     };

    size_t SerialTransport::bytesAvailable() const
    {
         return serial_port_.available();
    }

i get the error:
(in clang) member function 'available' not viable: 'this' argument has type 'const serial::Serial'

(in gcc) error: passing 'const serial::Serial' as 'this' argument of 'std::size_t serial::Serial::available' discards qualifiers [-fpermissive]
return serial_port_.available();

but if i define Serial::available() const in serial.cc, serial.h, also in the impl, it compiles.

@bakercp
Copy link
Contributor

bakercp commented Sep 3, 2014

Seems like a good idea to me, assuming the underlying implementations are const.

@wjwwood
Copy link
Owner

wjwwood commented Apr 22, 2015

Seems reasonable to me too, but I don't want to break API/ABI, so I labeled it as "Next API Change" and I'll try to do it then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants