Why Codes from MSDN can not compiled with February 2003 SDK?

This is a discussion on Why Codes from MSDN can not compiled with February 2003 SDK? within the Windows Programming forums, part of the Platform Specific Boards category; Hi there, The following codes are got from http://msdn2.microsoft.com/en-us/library/ms534078.aspx . But when it is compiled with VC 6.00 with February ...

  1. #1
    wow
    wow is offline
    Registered User
    Join Date
    Oct 2005
    Posts
    42

    Why Codes from MSDN can not compiled with February 2003 SDK?

    Hi there,

    The following codes are got from http://msdn2.microsoft.com/en-us/library/ms534078.aspx. But when it is compiled with VC 6.00 with February 2003 SDK, 102 errors are showed up as below. What's the problem? How is it resolved?

    Thanks,

    Code:
    #include "stdafx.h"
    #include <windows.h>
    #include <gdiplus.h>
    #include <stdio.h>
    using namespace Gdiplus;
    
    INT main()
    {
       // Initialize GDI+.
       GdiplusStartupInput gdiplusStartupInput;
       ULONG_PTR           gdiplusToken;
       GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
      
       UINT  num;        // number of image decoders
       UINT  size;       // size, in bytes, of the image decoder array
    
       ImageCodecInfo* pImageCodecInfo;
    
       // How many decoders are there?
       // How big (in bytes) is the array of all ImageCodecInfo objects?
       GetImageDecodersSize(&num, &size);
    
       // Create a buffer large enough to hold the array of ImageCodecInfo
       // objects that will be returned by GetImageDecoders.
       pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
    
       // GetImageDecoders creates an array of ImageCodecInfo objects
       // and copies that array into a previously allocated buffer. 
       // The third argument, imageCodecInfos, is a pointer to that buffer. 
       GetImageDecoders(num, size, pImageCodecInfo);
    
       // Display the graphics file format (MimeType)
       // for each ImageCodecInfo object.
       for(UINT j = 0; j < num; ++j)
       { 
          wprintf(L"%s\n", pImageCodecInfo[j].MimeType);   
       }
    
       free(pImageCodecInfo);
       GdiplusShutdown(gdiplusToken);
       return 0;
    }
    Compiling Errors:

    d:\program files\microsoft sdk\include\gdiplusimaging.h(67) : error C2501: 'MIDL_INTERFACE' : missing storage-class or type specifiers
    d:\program files\microsoft sdk\include\gdiplusimaging.h(67) : error C2440: 'initializing' : cannot convert from 'char [37]' to 'int'
    This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    d:\program files\microsoft sdk\include\gdiplusimaging.h(67) : error C2146: syntax error : missing ';' before identifier 'IImageBytes'
    d:\program files\microsoft sdk\include\gdiplusimaging.h(67) : error C2501: 'IImageBytes' : missing storage-class or type specifiers
    d:\program files\microsoft sdk\include\gdiplusimaging.h(67) : error C2239: unexpected token ':' following declaration of 'IImageBytes'
    d:\program files\microsoft sdk\include\gdiplusimaging.h(67) : error C2059: syntax error : 'public'
    d:\program files\microsoft sdk\include\gdiplusimaging.h(246) : error C2146: syntax error : missing ';' before identifier 'id'
    d:\program files\microsoft sdk\include\gdiplusimaging.h(246) : error C2501: 'PROPID' : missing storage-class or type specifiers
    d:\program files\microsoft sdk\include\gdiplusimaging.h(246) : error C2501: 'id' : missing storage-class or type specifiers
    d:\program files\microsoft sdk\include\gdiplusheaders.h(384) : error C2629: unexpected 'class Gdiplus::Image ('
    d:\program files\microsoft sdk\include\gdiplusheaders.h(384) : error C2238: unexpected token(s) preceding ';'
    d:\program files\microsoft sdk\include\gdiplusheaders.h(395) : error C2061: syntax error : identifier 'IStream'
    d:\program files\microsoft sdk\include\gdiplusheaders.h(405) : error C2061: syntax error : identifier 'IStream'
    d:\program files\microsoft sdk\include\gdiplusheaders.h(443) : error C2061: syntax error : identifier 'PROPID'
    d:\program files\microsoft sdk\include\gdiplusheaders.h(444) : error C2061: syntax error : identifier 'PROPID'
    d:\program files\microsoft sdk\include\gdiplusheaders.h(445) : error C2061: syntax error : identifier 'PROPID'
    d:\program files\microsoft sdk\include\gdiplusheaders.h(453) : error C2061: syntax error : identifier 'PROPID'
    d:\program files\microsoft sdk\include\gdiplusheaders.h(499) : error C2629: unexpected 'class Gdiplus::Bitmap ('
    d:\program files\microsoft sdk\include\gdiplusheaders.h(499) : error C2238: unexpected token(s) preceding ';'
    d:\program files\microsoft sdk\include\gdiplusheaders.h(510) : error C2061: syntax error : identifier 'IStream'
    d:\program files\microsoft sdk\include\gdiplusflat.h(1133) : error C2065: 'IStream' : undeclared identifier
    d:\program files\microsoft sdk\include\gdiplusflat.h(1133) : error C2065: 'stream' : undeclared identifier
    d:\program files\microsoft sdk\include\gdiplusflat.h(1133) : error C2065: 'image' : undeclared identifier
    d:\program files\microsoft sdk\include\gdiplusflat.h(1133) : error C2100: illegal indirection
    d:\program files\microsoft sdk\include\gdiplusflat.h(1133) : error C2275: 'GpImage' : illegal use of this type as an expression
    d:\program files\microsoft sdk\include\gdiplusgpstubs.h(61) : see declaration of 'GpImage'
    d:\program files\microsoft sdk\include\gdiplusflat.h(1133) : warning C4229: anachronism used : modifiers on data are ignored
    d:\program files\microsoft sdk\include\gdiplusflat.h(1133) : error C2078: too many initializers
    d:\program files\microsoft sdk\include\gdiplusflat.h(1139) : error C2100: illegal indirection
    d:\program files\microsoft sdk\include\gdiplusflat.h(1139) : error C2275: 'GpImage' : illegal use of this type as an expression
    d:\program files\microsoft sdk\include\gdiplusgpstubs.h(61) : see declaration of 'GpImage'
    d:\program files\microsoft sdk\include\gdiplusflat.h(1139) : warning C4229: anachronism used : modifiers on data are ignored
    d:\program files\microsoft sdk\include\gdiplusflat.h(1139) : error C2078: too many initializers
    d:\program files\microsoft sdk\include\gdiplusflat.h(1156) : error C2061: syntax error : identifier 'IStream'
    d:\program files\microsoft sdk\include\gdiplusflat.h(1244) : error C2061: syntax error : identifier 'PROPID'
    d:\program files\microsoft sdk\include\gdiplusflat.h(1247) : error C2061: syntax error : identifier 'PROPID'
    d:\program files\microsoft sdk\include\gdiplusflat.h(1250) : error C2061: syntax error : identifier 'PROPID'
    d:\program files\microsoft sdk\include\gdiplusflat.h(1262) : error C2061: syntax error : identifier 'PROPID'
    d:\program files\microsoft sdk\include\gdiplusflat.h(1275) : error C2065: 'bitmap' : undeclared identifier
    d:\program files\microsoft sdk\include\gdiplusflat.h(1275) : error C2100: illegal indirection
    d:\program files\microsoft sdk\include\gdiplusflat.h(1275) : error C2275: 'GpBitmap' : illegal use of this type as an expression
    d:\program files\microsoft sdk\include\gdiplusgpstubs.h(62) : see declaration of 'GpBitmap'

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    wow
    wow is offline
    Registered User
    Join Date
    Oct 2005
    Posts
    42
    Thanks for quick response. But what that means?

    Quote Originally Posted by Dave_Sinkula View Post
    gdiplusimaging.h is include file from the SDK. Do I need to trouble shot of it?
    Last edited by wow; 09-25-2007 at 08:04 PM.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    If I add that code in my MSVC v6 app it complies. I am using one of the 2003 SDKs.


    Have you 'pointed' MSVC at the SDK?

    [Tools]->[Options]

    Select the [Directories] TAB

    This dialog shows you what SDK you are currently using for Includes, Libs ect. Make sure that these ALL point to the right SDK.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    wow
    wow is offline
    Registered User
    Join Date
    Oct 2005
    Posts
    42
    Yes, both include and library are set properly. From the error message "d:\program files\microsoft sdk\include\gdiplusimaging.h(67)", you can see it has found the include file.

    After I change the include statements sequence, the errors as below:

    Compiling...
    imm.cpp
    D:\WindowsProgramming\Code\Chap14\imm\imm.cpp(10) : error C2871: 'Gdiplus' : does not exist or is not a namespace
    D:\WindowsProgramming\Code\Chap14\imm\imm.cpp(12) : error C2146: syntax error : missing ';' before identifier 'main'
    D:\WindowsProgramming\Code\Chap14\imm\imm.cpp(12) : error C2501: 'INT' : missing storage-class or type specifiers
    D:\WindowsProgramming\Code\Chap14\imm\imm.cpp(12) : fatal error C1004: unexpected end of file found
    Error executing cl.exe.

    imm.exe - 4 error(s), 0 warning(s)

    What's the problem now?

    Thanks,

    include statements:
    [CODE]
    #include <windows.h>
    #include <gdiplus.h>
    #include <stdio.h>
    #include "stdafx.h"
    {/CODE]
    Last edited by wow; 09-26-2007 at 08:46 PM.

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    What type of project did you create?

    Is it a WIN32/MFC app or a console app?

    You may have multiple copies of the GDIPlus header in diff SDKs (ie the one that came with MSVC v6).

    These versions may not all be compatible (ie using one version of the SDK lib and a diff SDK include may not work).
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  7. #7
    wow
    wow is offline
    Registered User
    Join Date
    Oct 2005
    Posts
    42
    It's a console program. The SDK is not come with MSVC 6.0. It's Feb 2003 SDK, the last one compatible with VC 6.0.

    I created another one Win32 app for it, but got the same errors.

    Thanks for your help,

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. DirectSound header issues
    By dxfoo in forum C++ Programming
    Replies: 0
    Last Post: 03-19-2006, 06:16 PM
  3. February 2003 SDK induced conflict?
    By McClane77 in forum Windows Programming
    Replies: 4
    Last Post: 08-25-2005, 05:48 AM
  4. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 06:05 PM
  5. FILES in WinAPI
    By Garfield in forum Windows Programming
    Replies: 46
    Last Post: 10-02-2003, 06:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21