C
Chris Cahoon
Hello,
I am trying to include a header file which was written in C, but my
project is in C++. Even when I wrap the include statement or the
entire header files with extern "C" (used according to the
instructions on c++-faq-lite), I get the same error, which is this:
invalid conversion from `int' to `DmtxDirection'
where DmtxDirection is an enum with integer values inside (obviously).
The offending function:
static DmtxDirection
TurnCorner(DmtxDirection dir, int turn)
{
DmtxDirection newDir;
newDir = (turn == DMTX_TURN_CW) ? 0x0f & (dir >> 1) : 0x0f & (dir
<< 1);
return (newDir) ? newDir : (dir ^ 0x0f) & 0x09;
}
And the enum:
typedef enum {
DmtxDirNone = 0x00,
DmtxDirUp = 0x01 << 0,
DmtxDirLeft = 0x01 << 1,
DmtxDirDown = 0x01 << 2,
DmtxDirRight = 0x01 << 3,
DmtxDirHorizontal = DmtxDirLeft | DmtxDirRight,
DmtxDirVertical = DmtxDirUp | DmtxDirDown,
DmtxDirRightUp = DmtxDirRight | DmtxDirUp,
DmtxDirLeftDown = DmtxDirLeft | DmtxDirDown
} DmtxDirection;
Long story short - should the extern "C" construct allow the library
to use enums in this manner, or do I need to take a different course?
Thanks for any advice.
Chris
I am trying to include a header file which was written in C, but my
project is in C++. Even when I wrap the include statement or the
entire header files with extern "C" (used according to the
instructions on c++-faq-lite), I get the same error, which is this:
invalid conversion from `int' to `DmtxDirection'
where DmtxDirection is an enum with integer values inside (obviously).
The offending function:
static DmtxDirection
TurnCorner(DmtxDirection dir, int turn)
{
DmtxDirection newDir;
newDir = (turn == DMTX_TURN_CW) ? 0x0f & (dir >> 1) : 0x0f & (dir
<< 1);
return (newDir) ? newDir : (dir ^ 0x0f) & 0x09;
}
And the enum:
typedef enum {
DmtxDirNone = 0x00,
DmtxDirUp = 0x01 << 0,
DmtxDirLeft = 0x01 << 1,
DmtxDirDown = 0x01 << 2,
DmtxDirRight = 0x01 << 3,
DmtxDirHorizontal = DmtxDirLeft | DmtxDirRight,
DmtxDirVertical = DmtxDirUp | DmtxDirDown,
DmtxDirRightUp = DmtxDirRight | DmtxDirUp,
DmtxDirLeftDown = DmtxDirLeft | DmtxDirDown
} DmtxDirection;
Long story short - should the extern "C" construct allow the library
to use enums in this manner, or do I need to take a different course?
Thanks for any advice.
Chris