Programming Tips - MyCtrl.odl(1): error MIDL2311: statements outside library block are illegal in mktyplib compatability mode : [ ]

Date: 2022oct25 Product: Microsoft Visual C++ Keywords: msvc, porting Language: C/C++ Q. MyCtrl.odl(1): error MIDL2311: statements outside library block are illegal in mktyplib compatability mode : [ ] A. Move the includes inside the library block Before
#include <idispids.h> #include <olectl.h> [ uuid(123-MYUID), version(1.0), helpfile("MyCtrl.hlp"), helpstring("MyCtrl ActiveX Control module"), control ] library MYCTRLLib { ...
After
[ uuid(123-MYUID), version(1.0), helpfile("MyCtrl.hlp"), helpstring("MyCtrl ActiveX Control module"), control ] library MYCTRLLib { #include <idispids.h> #include <olectl.h> ...