I have a legacy project where a MSVC-compiled Windows service accepts communications over RPC from a C++Builder-compiled Windows service. MSVC's MIDL compiler produces some C code to enable the RPC communications. I'm updating from BCB v6 to BCB v11.1.5 (clang compiler), and MSVC v6 to v2022.
However, the BCB clang compiler cannot compile the MIDL generated C code.
Here's a sample IDL file that causes issues:
import "oaidl.idl";
import "ocidl.idl";
[
uuid(e4122230-9f4d-11d2-8890-0060083b976d),
version(2.0),
pointer_default(unique)
]
interface TestCom
{
struct RPCTStatus
{
short ProcessState;
};
void ReadData([in] handle_t binding_handle,
[in] long _no,
[in] long stream,
[in, out] long* nbytes,
[out, size_is(, *nbytes)] byte** p_p_data,
[out] long* completion_code);
}
The MSVC MIDL compiler produces the following code for the client stub (this is just a snapshot):
#pragma warning( disable: 4211 ) /* redefine extern to static */
#pragma warning( disable: 4232 ) /* dllimport identity*/
#pragma warning( disable: 4024 ) /* array to pointer mapping*/
#pragma warning( disable: 4100 ) /* unreferenced arguments in x86 call */
/*lots of other code*/
extern const test_MIDL_TYPE_FORMAT_STRING test__MIDL_TypeFormatString;
extern const test_MIDL_PROC_FORMAT_STRING test__MIDL_ProcFormatString;
extern const test_MIDL_EXPR_FORMAT_STRING test__MIDL_ExprFormatString;
/*lots of other code*/
static const test_MIDL_TYPE_FORMAT_STRING test__MIDL_TypeFormatString =
{/*a big definition*/};
/*lots of other code*/
The BCB compiler complains:
[bcc32c Error] test_c.c: static declaration of 'test__MIDL_TypeFormatString' follows non-static declaration.
The #pragma warning( disable: 4211 )
allows MSVC to compile this, but I can't find:
A similar switch in BCB v11.1.5 to allow this construct (I've tried all the compatibility options I can find).
A way to stop the MIDL compiler from generating this construct.
It's not a decent option for me to switch back to the BCB 'classic' compiler (which will compile this) - the above code is in a static library that is linked into my BCB projects, along with many other libraries. I'd have to switch everything to 'classic' to make them link, and my feeling is I might as well leave it at the old BCB v6 if that's the only option.