1

I have a runtimeclass that I would like to add an enum to. I have tried the following syntax as suggested by the MSDN documentation here: https://learn.microsoft.com/en-ca/uwp/midl-3/intro

namespace my_project
{
    runtimeclass my_rt_class
    {        
        enum my_enum
        {
            first = 0,
            second = 1
        };
    }
}

However I get the following error from MIDL:

error MIDL2025: [msg]syntax error [context]: expecting an identifier near ";"

Whats the correct syntax for this? I am using version 10.0.17763.0 of the windows SDK.

mbl
  • 805
  • 11
  • 18

1 Answers1

5

You cannot nest enumerations in types. From the documentation you linked to:

The key organizational concepts in a MIDL 3.0 declaration are namespaces, types, and members. A MIDL 3.0 source file (an .idl file) contains at least one namespace, inside which are types and/or subordinate namespaces. Each type contains zero or more members.

  • Classes, interfaces, structures, and enumerations are types.
  • Fields, methods, properties, and events are examples of members.

Since enumerations are types, they must appear in a namespace. You will need to change your IDL to this:

namespace my_project
{
    enum my_enum
    {
        first = 0,
        second = 1
    };

    runtimeclass my_rt_class
    {        
    }
}
Community
  • 1
  • 1
IInspectable
  • 46,945
  • 8
  • 85
  • 181