c++cvisual-studiowdfiddcx

IddCX header results in errors for pure C compilation


I am trying to use pure C for a windows driver I am working on. Its a driver using IddCx (um/iddcx/iddcx.h). This header has a 'extern "c"` wrapper to allow for C compilation. The issue is the code within the 'extern "C"' block is not C. I get these two issues.

enum declarations like this:

enum IDDCX_MONITOR_MODE_ORIGIN : UINT
{
    IDDCX_MONITOR_MODE_ORIGIN_UNINITIALIZED = 0,
    /// <summary>
    /// Indicates that the driver added this mode from directly processing the monitor description
    /// </summary>
    IDDCX_MONITOR_MODE_ORIGIN_MONITORDESCRIPTOR = 1,
    /// <summary>
    /// Indicates that the driver did not add this mode as a direct resolution of processing the modes
    /// supported by the monitor but because of separate additional knowledge it has about the monitor
    /// </summary>
    IDDCX_MONITOR_MODE_ORIGIN_DRIVER = 2,
};

which results in errors like this (in C i dont think you can define a type for an Enum): error C2059: syntax error: ':'

and function declarations like this:

typedef
_Function_class_(EVT_IDD_CX_PARSE_MONITOR_DESCRIPTION)
_IRQL_requires_same_
NTSTATUS
NTAPI
EVT_IDD_CX_PARSE_MONITOR_DESCRIPTION(
    _In_
    const IDARG_IN_PARSEMONITORDESCRIPTION* pInArgs,
    _Out_
    IDARG_OUT_PARSEMONITORDESCRIPTION* pOutArgs
    );

which results in errors like this (due to structs not given a typedef, and therefore needing to be prefixed with "struct"): error C2143: syntax error: missing ')' before '*'

error C2143: syntax error: missing '{' before '*'

error C2143: syntax error: missing ';' before '*'

warning C4218: nonstandard extension used: must specify at least a storage class or a type error C2059: syntax error: ')'

warning C4218: nonstandard extension used: must specify at least a storage class or a type

If the header didnt have any extern C wrappers, I would assume its a Cpp only API and use Cpp instead. But it does have them, so it should compile just fine. Either there is some flag I need to set for this to work, or this is a mistake on microsoft's part. If its a mistake on their part ill report the bug and create my own header to use for now.

Also, is there a place where I should be reporting this to microsoft if it is a bug?


Solution

  • IddCx seems to suppose to be C compliant, but its not. I have reported the issue to microsoft. I have created a temporary custom header file that is compliant. It compiles just fine now.