Take the 2-minute tour ×

Is there a utility for compiling the .ridl file used by C++Builder, to generate a C header?

As far as I can tell, TLIBIMP can only extract RIDL from TLB, and generate C++ headers from TLB. I do not see an option to generate headers from RIDL.

Using the Microsoft SDK 7.1's "midl.exe" on the .ridl file I get a bunch of errors:

.\MyObject.ridl(114) : error MIDL2072 : inapplicable attribute : [version] [ Parameter 'param1' of Procedure 'func1' ( Interface 'IMyObject' ) ]

Also there are some good warnings:

.\MyObject.ridl(343) : warning MIDL2400 : for oleautomation, optional parameters should be VARIANT or VARIANT * : [optional] [ Parameter 'param2' of Procedure 'func2' ( Interface 'IMyObject' ) ]

which I since learned about, but didn't know when originally defining my interface. It'd be good to have these sort of warnings available when defining an interface in C++Builder.

I'm guessing that .ridl is an extension invented by Embarcadero, and [version] is a tag in that extension. The error specifically refers to the version(1.0) that appears in the header for enums that I defined. (Each use of an enum as function parameter triggers the warning).

(If I fix the errors by removing this excess version tag then it generates headers correctly that I can use in a C program built with C++Builder).

share|improve this question

1 Answer 1

up vote 2 down vote accepted

A RIDL file is specific to Embarcadero compilers only. Embarcadero uses RIDL instead of standard IDL, and RIDL is not compatible with MIDL.exe.

In pre-2009 versions, the IDE edited the TLB file directly, and then linked it as-is into executables. This was error-prone, hard to maintain and edit, and did not lend itself well to VCS systems. So RIDL was created, and TLB files became intermediate files created dynamically during project compiling, like OBJ and RES files.

There is no tool to create C/C++ source files directly from a RIDL file. However, there is a GenTLB.exe tool to create a TLB file from a RIDL file, and then you can use the TLIBIMP.exe tool to create C/C++ source files from the TLB file.

Note, however, that the C/C++ source files generated by TLIBIMP.exe are only usable in C++Builder, as they rely on Embarcadero-specific compiler extensions and RTL headers/types. If you want to use the TLB file with other compilers, you will have to use their own TLB import tools/capabilities.

share|improve this answer
Thanks Remy. I actually was able to generate C headers using MIDL after editing out the Embarcadero extension. –  Matt McNabb Jul 28 at 3:12
Corollary question, is there documentation anywhere of exactly what the Embarcadero extensions are (above MIDL specification)? –  Matt McNabb Jul 28 at 3:22
The [version] attribute is not specific to Embarcadero, Microsoft uses it too, see interface attribute and version attribute. RIDL is a restricted IDL, Embarcadero omitted things from RIDL, they did not add custom things to it. Sounds more like a bug in your version of MIDL. –  Remy Lebeau Jul 28 at 6:37
As mentioned in my post, it is only the use of version with an enum that triggers the error in MIDL 7.00.0555. The MSDN page is unclear whether that is a permitted use of it (although I don't see why it shouldn't be). I'll post a new question –  Matt McNabb Jul 28 at 20:56
I don't think MIDL supports versioning enums: enum attribute. The only attribute I see applicable to an enum is [v1_enum]. It looks like [version] only applies to interfaces and coclasses. –  Remy Lebeau Jul 28 at 21:19

Your Answer


