Compile errors in a MIDL generated _i.c file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bradyounie
    New Member
    • Aug 2008
    • 20

    Compile errors in a MIDL generated _i.c file

    I have a C++ COM project that was created with Visual C++ 6. I have just converted the project to Visual Studio 2005 and have been trying to build it. I get the following compile errors:

    Code:
    warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
    error C2143: syntax error : missing ';' before '__uuidof'
    error C2059: syntax error : '__uuidof'
    error C2143: syntax error : missing ';' before '{'
    error C2447: '{' : missing function header (old-style formal list?)
    The problem is that these compile errors are in a myproject_i.c file that is auto-generated by the MIDL program. How can I force MIDL to generate code that doesn't have these errors?

    Could this be an artifact of the project being converted from VC6?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Nice errors. Too bad I can't see the code.

    Comment

    • bradyounie
      New Member
      • Aug 2008
      • 20

      #3
      Originally posted by weaknessforcats
      Nice errors. Too bad I can't see the code.
      Good point. Duh. Sorry about that.

      Here's the snippet of generated code that has the error:

      Code:
      #define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
              const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
      
      MIDL_DEFINE_GUID(IID, IID_IResponse,0xCEB229AF,0x9439,0x43E7,0xB5,0xE1,0xB6,0xE2,0xC7,0xCB,0x2E,0xA7);
      
      MIDL_DEFINE_GUID(IID, IID_ITransactionElement,0xA1650A7E,0x54D5,0x4f66,0x80,0x6B,0x40,0x28,0xCF,0xB6,0xC2,0x56);
      
      MIDL_DEFINE_GUID(IID, IID_ITransaction,0xEFCFCD13,0xBE86,0x4793,0xA1,0x4C,0x8D,0x55,0x07,0x1B,0x2A,0x27);
      The last line of code is the one that produces all four errors.

      There must be a file that MIDL uses to determine how to generate the above code.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Did you #include <windows.h> ?

        I did and your errors went away.

        Comment

        • bradyounie
          New Member
          • Aug 2008
          • 20

          #5
          Originally posted by weaknessforcats
          Did you #include <windows.h> ?

          I did and your errors went away.
          I did just now, with no luck. I have one source file including the _i.c file, so I included <windows.h> before that include. No dice. I get the same errors.

          Comment

          • weaknessforcats
            Recognized Expert Expert
            • Mar 2007
            • 9214

            #6
            Maybe you could post the code?

            You haven't disabled language extensions have you? __uuidof is a Microsoft-only C++ extension.

            Comment

            • bradyounie
              New Member
              • Aug 2008
              • 20

              #7
              I figured it out about an hour ago.

              The line it was complaining about was the IID_ITransactio n one. Windows already defines an IID_ITransactio n. For some reason, MSVC 6 didn't complain about it, but VS 2005 does. If I change my interface name, it builds fine.

              The errors it gave weren't very helpful. In fact, they led me in the wrong direction, but at least I figured it out.

              Thanks for the help.

              Comment

              • weaknessforcats
                Recognized Expert Expert
                • Mar 2007
                • 9214

                #8
                You might try this with VS 2008 especially since even this version is on its way out.

                MS keeps tightening up the compiler.

                Comment

                • bradyounie
                  New Member
                  • Aug 2008
                  • 20

                  #9
                  Tried that. Did the same thing. Plus, I was told to use 2005 for this project.

                  Comment

                  Working...