Can't #Include <gdiplus.h> to my Win32 application

Hello,

      I'm trying to use my native code that using GDI+ in my CLR application using the Visual Studio 2003 but it refuses to include gdiplus.h But it generate many and many of errors to me and I show you few of them below:

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(67) : error C2501: 'MIDL_INTERFACE' : missing storage-class or type specifiers

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(67) : error C2440: 'initializing' : cannot convert from 'const char [37]' to 'int'

This conversion requires a reinterpret_cast, a C-style cast or function-style cast

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(67) : error C2146: syntax error : missing ';' before identifier 'IImageBytes'

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(67) : error C2470: 'IImageBytes' : looks like a function definition, but there is no formal parameter list; skipping apparent body

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(67) : error C2059: syntax error : 'public'

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(246) : error C2146: syntax error : missing ';' before identifier 'id'

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(246) : error C2501: 'Gdiplus::PropertyItem::PROPID' : missing storage-class or type specifiers

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(246) : error C2501: 'Gdiplus::PropertyItem::id' : missing storage-class or type specifiers

      And many and many of that . I don't know what to do . But when I tried to use the same code in a new WIN32 application It refuses too and generates these errors.

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(67) : error C2501: 'MIDL_INTERFACE' : missing storage-class or type specifiers

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(67) : error C2440: 'initializing' : cannot convert from 'const char [37]' to 'int'

This conversion requires a reinterpret_cast, a C-style cast or function-style cast

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(67) : error C2146: syntax error : missing ';' before identifier 'IImageBytes'

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(67) : error C2470: 'IImageBytes' : looks like a function definition, but there is no formal parameter list; skipping apparent body

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(67) : error C2059: syntax error : 'public'

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(246) : error C2146: syntax error : missing ';' before identifier 'id'

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(246) : error C2501: 'Gdiplus::PropertyItem::PROPID' : missing storage-class or type specifiers

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusImaging.h(246) : error C2501: 'Gdiplus::PropertyItem::id' : missing storage-class or type specifiers

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusHeaders.h(384) : error C2143: syntax error : missing ')' before '*'

       And as I think it's the same type of the errors generated from the CLR application.
Can any body help

Thanks,
Mustafa ELBanna



Answer this question

Can't #Include <gdiplus.h> to my Win32 application

  • Mattias Jonsson

    Then it could be something different in your stdafx.h you were using.

    Try to do changes so that you have the previous code and see which change exactly leads to the errors.

    Thanks,
      Ayman Shoukry
      VC++ Team


  • Jeaux

    Hello,
          I simply wrote this as you said and it worked!!:-)

    #include <Windows.h>

    #include <gdiplus.h>

    using namespace Gdiplus;

    #include <iostream>

    int main()

    {

    return 0;

    }
    Thanks,
    Mustafa ELBanna


  • DougS

    Try including windows.h before gdiplus.h. I just tried it using VC2005 and it compiled with nor errors.

    Thanks,
      Ayman Shoukry
      VC++ Team

  • Eric Sanders

    What I was telling you is that it is not a problem in the headers but might be in the way they are included. What I wanted you to do is to see the difference between the project that was causing the errors and the one compiling with no errors. The difference could explain the cause of the errors.

    Any ways, if you are using the Express SKU of VC2005, here is a good link on how to use the Platform SDK headers with it:
    http://lab.msdn.microsoft.com/express/visualc/usingpsdk/default.aspx

    Hope this helps!

    Thanks,
      Ayman Shoukry
      VC++ Team

  • Sam Larko

    I really can't understand, but what if I tell you that I test now to use Windows.h on Visual C++ Express 2005 and it refuses to work although I copied the include and the libarary files of the platform SDK into VC8 directories!!
    Thanks.


  • KJ-JC1974

    Could you try just an empty win32 console application and just add you includes and the main method and see if the errors reproduce

    Thanks,
      Ayman Shoukry
      VC++ Team

  • ChrislRoy

    When you generate the C++ Win32 project the stdafx.h will contain a number of #defines and #includes. This is the one you want to comment out in order to get gdiplus.h to compile:

    #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers

    WIN32_LEAN_AND_MEAN prevents a lot of stuff from being included. Just comment it out. That's all there is to it. Smile

  • Belazor

    Could you post a small sample including how you are including the header files I can then try to reproduce it on my machine.

    Thanks,
      Ayman Shoukry
      VC++ Team

  • jeroln

    Hello,
           I just tried to make a simple WIN32 APP use the GDI+ for a test and it fails too. All I make just include <gdiplus.h> at stdafx.h after Windows.h, but it didn't works. I put it in the CPP files that I use it generates the same messages that I showed a sample from it in my first post!
    Thanks,
    Mustafa ELBanna


  • Chandra Murali

    Hello,
           First, Thanks for replying. Second, It doesn't really appear to work on any Visual Studio Version and I tried to see if any project setting are missed up but I can't find any something strange too.
    Thanks,
    Mustafa ELBanna

  • Can't #Include <gdiplus.h> to my Win32 application