Visual C++ Compiler Warning C4199

Message Text

text

Circumstances (External)

This warning serves mainly, but not solely, as a placeholder for warnings generated externally to the compiler. The warning level is entirely in the hands of the external component. So too is the message text, which is why it is shown simply as text above. For this mechanism to be useful, the text would describe the error in some detail, perhaps even with its own scheme of error numbers.

The external component will be an attribute provider DLL, such as ATLPROV. Indeed, since Microsoft does not document how to write attribute providers and ATLPROV is the only attribute provider DLL that Microsoft supplies with Visual C++, ATLPROV is in practice the only cause of externally generated C4199 warnings.

ATL Warnings

All ATL warnings generated by ATLPROV feed back to the compiler as C4199 (mostly at level 3). The most common form for the whole warning message is:

position : warning C4199: attribute
        Atl Attribute Provider : warning ATLnumber: message

where position (the file name and line number) is generated by the compiler, as usual, but everything from attribute onwards is from ATLPROV, including most notably the ATL warning number and message text.

Disguised ATL Warnings

In a few cases however, the ATL message text becomes the whole of the message text for compiler warning C4199. The whole warning message is just

position : warning C4199: text

as if generated internally by the compiler. There is no ATL warning number, no indication that the warning originated with the ATL Attribute Provider, and no help from the product documentation, which omits C4199 from its list of C/C++ Build Errors. When the text is one of

programmers should understand that they are actually dealing with ATL warnings ATL4001, ATL4002, ATL4003 and ATL4005 respectively.

Circumstances (Internal)

In one case, the compiler may itself raise warning C4199, with the compiler’s own message text. When evaluating arguments passed to a custom attribute, the compiler allows typeof as a synonym of __typeof, but with a warning (at level 1). The message text is

please use __typeof

For an example, compile the minimal but nonsensical

#using  <mscorlib.dll>
using namespace System;

[
    attribute (All)
]
__gc class Test
{
    public: Test (Type *);
};

[
    module:Test (typeof (Test));
];                                      // C4199

with the /clr option.

Documentation Status

As noted above, the product documentation does not list warning C4199 among the C/C++ Build Errors. This warning’s existence and (main) purpose are however disclosed in the documentation of the /Fx option, which reproduces the directive

#pragma warning(disable: 4199) // Suppress warnings from attribute providers

that appears near the top of every compiler-generated “merged injected text” file.