K
Kurt
Hi. I have a c++ project that is basically a set of implementation
hiding classes, so that we can convert a static lib with a lot of
dependancies into a dynamic lib with less dependancies, so that users
of the lib dont require all the development tools we used to develop
the lib.
I have noticed something strange, and was wondering if its a C++
feature, or a implementation specific bug.
I have a function like this:
CheckerErrorId CCheckerError::GetErrorId()
{
ECheckerError ce = pimpl->getC_ErrorId();
switch (ce)
{
case CINFO:
return CINFO;
case CHWARNING_bus_blocked_yet:
return CHWARNING_bus_blocked_yet;
case CHWARNING_no_output_message_defined:
return CHWARNING_no_output_message_defined;
// Rest of list omitted.
default:
return CHERROR_unknown;
}
}
This function converts the internally used ECheckerError enum (as
defined in the original static libs header files) into the equivalent
CheckerErrorId as defined in my dynamic lib.
However the compiler seems to treat ce as if it were a CheckerErrorId
rather than a ECheckerError. pimpl->getC_ErrorId() could return CINFO,
but the switch statement seems to skip to the case that CINFO matches
in the list of Checker.
Internal enum looks something like this (most of it removed):
enum ECheckerError {
CHERROR_unknown,
CHWARNING_bus_blocked_yet,
CHWARNING_no_output_message_defined,
CINFO
};
CheckerErrorId looks like :
enum CheckerErrorId {
CHERROR_unknown,
CHWARNING_bus_blocked_yet,
CHWARNING_bus_undefined,
CHWARNING_no_output_message_defined,
TPCHWARNING_wrong_generalTimeout_time,
CINFO
};
So if pimpl->getC_ErrorId() returns CINFO, then it jumps down to the
case for CHWARNING_no_output_message_defined.
If we use if and == then the problem remains. The compiler seems to
ignore the fact that ce is a ECheckerError, and treats it like it were
a CheckerErrorId, or perhaps as if they were merely #defines or
something, simply replacing them by their integer representations!
My question is, is this standard c++ behavior or a possible compiler
bug?
Thanks a lot gurus.
Kurt
hiding classes, so that we can convert a static lib with a lot of
dependancies into a dynamic lib with less dependancies, so that users
of the lib dont require all the development tools we used to develop
the lib.
I have noticed something strange, and was wondering if its a C++
feature, or a implementation specific bug.
I have a function like this:
CheckerErrorId CCheckerError::GetErrorId()
{
ECheckerError ce = pimpl->getC_ErrorId();
switch (ce)
{
case CINFO:
return CINFO;
case CHWARNING_bus_blocked_yet:
return CHWARNING_bus_blocked_yet;
case CHWARNING_no_output_message_defined:
return CHWARNING_no_output_message_defined;
// Rest of list omitted.
default:
return CHERROR_unknown;
}
}
This function converts the internally used ECheckerError enum (as
defined in the original static libs header files) into the equivalent
CheckerErrorId as defined in my dynamic lib.
However the compiler seems to treat ce as if it were a CheckerErrorId
rather than a ECheckerError. pimpl->getC_ErrorId() could return CINFO,
but the switch statement seems to skip to the case that CINFO matches
in the list of Checker.
Internal enum looks something like this (most of it removed):
enum ECheckerError {
CHERROR_unknown,
CHWARNING_bus_blocked_yet,
CHWARNING_no_output_message_defined,
CINFO
};
CheckerErrorId looks like :
enum CheckerErrorId {
CHERROR_unknown,
CHWARNING_bus_blocked_yet,
CHWARNING_bus_undefined,
CHWARNING_no_output_message_defined,
TPCHWARNING_wrong_generalTimeout_time,
CINFO
};
So if pimpl->getC_ErrorId() returns CINFO, then it jumps down to the
case for CHWARNING_no_output_message_defined.
If we use if and == then the problem remains. The compiler seems to
ignore the fact that ce is a ECheckerError, and treats it like it were
a CheckerErrorId, or perhaps as if they were merely #defines or
something, simply replacing them by their integer representations!
My question is, is this standard c++ behavior or a possible compiler
bug?
Thanks a lot gurus.
Kurt