[libhid-discuss] unable to include hid.h in C++

Charles Lepple clepple at ghz.cc
Mon Oct 25 23:32:56 UTC 2010


On Oct 25, 2010, at 6:21 PM, Donald Kayser wrote:

> 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.

> 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++.



More information about the libhid-discuss mailing list