[libhid-discuss] Problem compiling C++ programs with libhid
Marian Aldenhoevel
marian.aldenhoevel at marian-aldenhoevel.de
Sun Aug 24 08:08:40 UTC 2008
Hi,
> I'm having a problem using the headers from libhid, specifically hid.h.
> If I use it in a .c file it compiles fine, but if I rename the file to
> .cpp I get a bunch of errors.
> "In file included from brokenhid.c:1:
> /usr/include/hid.h:72: error: typedef ‘_Bool’ is initialized (use
> __typeof__ instead)
> /usr/include/hid.h:72: error: ‘matcher_fn_t’ was not declared in this scope
> /usr/include/hid.h:79: error: ‘matcher_fn_t’ does not name a type
> /usr/include/hid.h:124: error: ‘_Bool’ does not name a type
> /usr/include/hid.h:133: error: ‘_Bool’ does not name a type"
I am using libhid in a C++ program and it works fine. I have come across
the same problem, though. I think you want to include <stdbool.h> if you
have it.
#include <stdbool.h>
#include <hid.h>
int main()
{
HIDInterfaceMatcher broken;
return 0;
}
I do not exactly know why, because hid.h does test for it and has #defines
to define it's own version of _Bool. So it should work without stdbool.h
as well.
In my case I use autoconf/automake and the AC_HEADER_STDBOOL macro. That
checks for the presence of stdbool.h and if found defines HAVE_STDBOOL_H
which then makes hid.h include <stdbool.h> and everything is fine.
The autotools make life a lot easier.
Ciao, MM
More information about the libhid-discuss
mailing list