hparra / ruby-serialport

ruby-serialport is a Ruby library that provides a class for using RS-232 serial ports
http://rubygems.org/gems/serialport
GNU General Public License v2.0
246 stars 58 forks source link

posix_serialport_impl.c: error: incompatible pointer to integer #74

Open listout opened 1 year ago

listout commented 1 year ago

Clang 15 has enabled -Werror=int-conversion by default. Hence, we now get

posix_serialport_impl.c:113:13: error: incompatible pointer to integer
conversion passing 'struct RFile *' to parameter of type 'VALUE'
(aka 'unsigned long') [-Wint-conversion]
OBJSETUP(sp, class, T_FILE);
^~
This commit should fix this build error.

First discovered: https://bugs.gentoo.org/883127

diff --git a/ext/native/posix_serialport_impl.c b/ext/native/posix_serialport_impl.c
index 2f9325e..b43be30 100644
--- a/ext/native/posix_serialport_impl.c
+++ b/ext/native/posix_serialport_impl.c
@@ -110,7 +110,7 @@ VALUE sp_create_impl(class, _port)
    struct termios params;

    NEWOBJ(sp, struct RFile);
-   OBJSETUP(sp, class, T_FILE);
+   OBJSETUP((VALUE)sp, class, T_FILE);
    MakeOpenFile((VALUE) sp, fp);

    switch(TYPE(_port))

Fixes it.

Would love to send in PR, just don't have a access to fork the repo.

natpicone commented 11 months ago

@hparra Do you have a plan to fix this?

tenderlove commented 7 months ago

If you need to do serial port work, please try this gem. I don't want to maintain the serialport gem anymore and have developed an alternative

larskanis commented 3 days ago

As a quick workaround you can use either: gem install serialport -- --with-cflags=-Wno-int-conversion or with bundler: bundle config build.serialport -- --with-cflags=-Wno-int-conversion