Discussion:
[libhid-discuss] unable to include hid.h in C++
Donald Kayser
2010-10-25 22:21:23 UTC
Permalink
I am unable to use libhid with a c++ application since hid.h redefines
bool.

On lines around line 20 there is a macro
#define bool _Bool
#define true 1
#define false 0

It is not legal to redefine reserved words.

Has anyone else attempted to use libhid in a C++ application, and if
so, what did you do to get around this?

Thanks,
Donald Kayser
Charles Lepple
2010-10-25 23:32:56 UTC
Permalink
Post by Donald Kayser
I am unable to use libhid with a c++ application since hid.h
redefines bool.
On lines around line 20 there is a macro
#define bool _Bool
#define true 1
#define false 0
It is not legal to redefine reserved words.
This kludge only comes into play if you do not have stdbool.h.
Post by Donald Kayser
Has anyone else attempted to use libhid in a C++ application, and if
so, what did you do to get around this?
I think someone posted their source code to the list for getting
libhid to compile under Visual Studio - maybe that will help.

A lot of people have had success recently with HIDAPI, so you might
want to look into that instead of libhid:

http://www.signal11.us/oss/hidapi/

It wraps a bunch of things in "#ifdef __cplusplus" so there's a chance
that someone is using it with C++.
Donald Kayser
2010-10-29 13:01:16 UTC
Permalink
Thanks for the suggestion of HIDAPI, but it does not claim to be
usable in Linux/g++ world. Also, from what I have been able to find,
<stdbool.h> does exactly the same kludge with bool, so it won't work.
I suppose I will get the source and build my own version and delete
the offending code. Sure would be nice if it worked as claimed.

Donald
Post by Charles Lepple
Post by Donald Kayser
I am unable to use libhid with a c++ application since hid.h
redefines bool.
On lines around line 20 there is a macro
#define bool _Bool
#define true 1
#define false 0
It is not legal to redefine reserved words.
This kludge only comes into play if you do not have stdbool.h.
Post by Donald Kayser
Has anyone else attempted to use libhid in a C++ application, and
if so, what did you do to get around this?
I think someone posted their source code to the list for getting
libhid to compile under Visual Studio - maybe that will help.
A lot of people have had success recently with HIDAPI, so you might
http://www.signal11.us/oss/hidapi/
It wraps a bunch of things in "#ifdef __cplusplus" so there's a
chance that someone is using it with C++.
Peter Stuge
2010-10-29 13:30:10 UTC
Permalink
Thanks for the suggestion of HIDAPI, but it does not claim to be usable
in Linux/g++ world.
HIDAPI will work fine also in Linux. C or C++ doesn't matter much,
you'd just need to wrap the header in extern C if it isn't already,
right?


//Peter
Donald Kayser
2010-10-29 14:17:50 UTC
Permalink
Thanks Peter. It is more than that actually, since it is not 'free'
GPL code I won't use it. I have decide to use the libusb interface
instead.

Donald
Post by Peter Stuge
Thanks for the suggestion of HIDAPI, but it does not claim to be usable
in Linux/g++ world.
HIDAPI will work fine also in Linux. C or C++ doesn't matter much,
you'd just need to wrap the header in extern C if it isn't already,
right?
//Peter
_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/
Peter Stuge
2010-10-29 14:28:06 UTC
Permalink
Thanks Peter. It is more than that actually, since it is not 'free' GPL
code I won't use it. I have decide to use the libusb interface instead.
"HIDAPI may be used by anyone for any reason so long as the coypright
header in the source code remains intact." - correct, not GPL.

libusb is LGPL as you may know.


//Peter
Charles Lepple
2010-10-29 23:53:40 UTC
Permalink
Post by Peter Stuge
Thanks Peter. It is more than that actually, since it is not 'free' GPL
code I won't use it. I have decide to use the libusb interface instead.
"HIDAPI may be used by anyone for any reason so long as the coypright
header in the source code remains intact." - correct, not GPL.
http://github.com/signal11/hidapi/blob/master/LICENSE.txt mentions GPL
as an option.
Xiaofan Chen
2010-10-30 08:43:16 UTC
Permalink
Post by Charles Lepple
http://github.com/signal11/hidapi/blob/master/LICENSE.txt mentions
GPL as an option.
HIDAPI can be used under one of three licenses, which is very liberal.

1. The GNU Public License, version 3.0, in LICENSE-gpl3.txt
2. A BSD-Style License, in LICENSE-bsd.txt.
3. The more liberal original HIDAPI license. LICENSE-orig.txt
--
Xiaofan
Donald Kayser
2010-10-30 16:01:09 UTC
Permalink
I let the legal department figure out this stuff. I looked briefly at
the website of HIDAPI and they wanted money, so it is no-go. I don't
need cross-platform support, Windows and HID devices and our
application have a completely different mechanisms in Windows and Linux.

So, I have moved on. libusb-1.0 has all of the API that I need to
detach the kernel HID driver, which is necessary for our use.
Post by Xiaofan Chen
Post by Charles Lepple
http://github.com/signal11/hidapi/blob/master/LICENSE.txt mentions
GPL as an option.
HIDAPI can be used under one of three licenses, which is very liberal.
1. The GNU Public License, version 3.0, in LICENSE-gpl3.txt
2. A BSD-Style License, in LICENSE-bsd.txt.
3. The more liberal original HIDAPI license. LICENSE-orig.txt
--
Xiaofan
_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/
Peter Stuge
2010-10-30 16:58:55 UTC
Permalink
I let the legal department figure out this stuff. I looked briefly at the
website of HIDAPI and they wanted money, so it is no-go.
You are looking at the wrong HIDAPI website. I'll include the link
again in this thread:

http://www.signal11.us/oss/hidapi/
So, I have moved on. libusb-1.0 has all of the API that I need to
detach the kernel HID driver, which is necessary for our use.
If a Linux-specific solution is acceptable then see if you can use
hidraw or hiddev instead. (Those are kernel APIs.)


//Peter

Charles Lepple
2010-10-30 00:06:49 UTC
Permalink
Post by Donald Kayser
Sure would be nice if it worked as claimed.
We can fix that...

I see one tangential mention of libhid and C++ in the home page (the
"time of writing" was 2005; this doesn't count the description of
SWIG). Where else should I remove any C++ compatibility claims?
Loading...