Helpful Information
 
 
Category: C++
C++ >> Windows GDI+ Not Working.

i tried using it for the first time and it throws all these errors. even when i don't use any of the commands from it. just #including it makes this happen


c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusimaging.h(74) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusimaging.h(74) : error C2440: 'initializing' : cannot convert from 'const char [37]' to 'int'
There is no context in which this conversion is possible
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusimaging.h(74) : error C2146: syntax error : missing ';' before identifier 'IImageBytes'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusimaging.h(74) : error C2470: 'IImageBytes' : looks like a function definition, but there is no parameter list; skipping apparent body
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusimaging.h(74) : error C2059: syntax error : 'public'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusimaging.h(280) : error C2146: syntax error : missing ';' before identifier 'id'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusimaging.h(280) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusimaging.h(280) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(384) : error C2061: syntax error : identifier 'IStream'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(395) : error C2061: syntax error : identifier 'IStream'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(405) : error C2061: syntax error : identifier 'IStream'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(443) : error C2061: syntax error : identifier 'PROPID'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(444) : error C2061: syntax error : identifier 'PROPID'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(445) : error C2061: syntax error : identifier 'PROPID'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(453) : error C2061: syntax error : identifier 'PROPID'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(471) : error C2535: 'Gdiplus::Image::Image(void)' : member function already defined or declared
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(384) : see declaration of 'Gdiplus::Image::Image'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(505) : error C2061: syntax error : identifier 'IStream'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(516) : error C2061: syntax error : identifier 'IStream'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(758) : error C2061: syntax error : identifier 'IStream'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(813) : error C2061: syntax error : identifier 'IStream'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(813) : error C2535: 'Gdiplus::Metafile::Metafile(void)' : member function already defined or declared
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(758) : see declaration of 'Gdiplus::Metafile::Metafile'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(820) : error C2061: syntax error : identifier 'IStream'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(820) : error C2535: 'Gdiplus::Metafile::Metafile(void)' : member function already defined or declared
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(758) : see declaration of 'Gdiplus::Metafile::Metafile'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(829) : error C2061: syntax error : identifier 'IStream'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(829) : error C2535: 'Gdiplus::Metafile::Metafile(void)' : member function already defined or declared
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(758) : see declaration of 'Gdiplus::Metafile::Metafile'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(855) : error C2061: syntax error : identifier 'IStream'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(923) : error C2535: 'Gdiplus::Metafile::Metafile(void)' : member function already defined or declared
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusheaders.h(758) : see declaration of 'Gdiplus::Metafile::Metafile'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1133) : error C2065: 'IStream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1133) : error C2065: 'stream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1133) : error C2065: 'image' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1133) : error C2275: 'Gdiplus::GpImage' : illegal use of this type as an expression
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusgpstubs.h(61) : see declaration of 'Gdiplus::GpImage'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1133) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1133) : error C2078: too many initializers
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1139) : error C2065: 'IStream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1139) : error C2065: 'stream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1139) : error C2065: 'image' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1139) : error C2275: 'Gdiplus::GpImage' : illegal use of this type as an expression
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusgpstubs.h(61) : see declaration of 'Gdiplus::GpImage'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1139) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1139) : error C2078: too many initializers
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1156) : error C2061: syntax error : identifier 'IStream'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1244) : error C2061: syntax error : identifier 'PROPID'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1247) : error C2061: syntax error : identifier 'PROPID'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1250) : error C2061: syntax error : identifier 'PROPID'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1262) : error C2061: syntax error : identifier 'PROPID'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1286) : error C2065: 'IStream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1286) : error C2065: 'stream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1286) : error C2065: 'bitmap' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1286) : error C2275: 'Gdiplus::GpBitmap' : illegal use of this type as an expression
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusgpstubs.h(62) : see declaration of 'Gdiplus::GpBitmap'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1286) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1286) : error C2078: too many initializers
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1292) : error C2065: 'IStream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1292) : error C2065: 'stream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1292) : error C2065: 'bitmap' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1292) : error C2275: 'Gdiplus::GpBitmap' : illegal use of this type as an expression
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusgpstubs.h(62) : see declaration of 'Gdiplus::GpBitmap'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1292) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(1292) : error C2078: too many initializers
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2222) : error C2065: 'IStream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2222) : error C2065: 'stream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2224) : error C2065: 'header' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2224) : error C2275: 'Gdiplus::MetafileHeader' : illegal use of this type as an expression
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetaheader.h(112) : see declaration of 'Gdiplus::MetafileHeader'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2224) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2224) : error C2078: too many initializers
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2242) : error C2061: syntax error : identifier 'IStream'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2262) : error C2065: 'IStream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2262) : error C2065: 'stream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2262) : error C2065: 'metafile' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2262) : error C2275: 'Gdiplus::GpMetafile' : illegal use of this type as an expression
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusgpstubs.h(63) : see declaration of 'Gdiplus::GpMetafile'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2262) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2262) : error C2078: too many initializers
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2309) : error C2065: 'IStream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2309) : error C2065: 'stream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2310) : error C2275: 'HDC' : illegal use of this type as an expression
c:\program files\microsoft sdks\windows\v6.0a\include\windef.h(267) : see declaration of 'HDC'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2310) : error C2146: syntax error : missing ')' before identifier 'referenceHdc'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2310) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2310) : error C2078: too many initializers
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2310) : error C2275: 'HDC' : illegal use of this type as an expression
c:\program files\microsoft sdks\windows\v6.0a\include\windef.h(267) : see declaration of 'HDC'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2316) : error C2059: syntax error : ')'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2320) : error C2065: 'IStream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2320) : error C2065: 'stream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2321) : error C2275: 'HDC' : illegal use of this type as an expression
c:\program files\microsoft sdks\windows\v6.0a\include\windef.h(267) : see declaration of 'HDC'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2321) : error C2146: syntax error : missing ')' before identifier 'referenceHdc'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2321) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2321) : error C2078: too many initializers
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2321) : error C2275: 'HDC' : illegal use of this type as an expression
c:\program files\microsoft sdks\windows\v6.0a\include\windef.h(267) : see declaration of 'HDC'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusflat.h(2327) : error C2059: syntax error : ')'
c:\program files\microsoft sdks\windows\v6.0a\include\gdipluspath.h(133) : error C2061: syntax error : identifier 'byte'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(75) : error C2065: 'IStream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(75) : error C2065: 'stream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(76) : error C2448: 'Gdiplus::Metafile::{ctor}' : function-style initializer appears to be a function definition
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(194) : error C2065: 'IStream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(194) : error C2065: 'stream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(195) : error C2275: 'HDC' : illegal use of this type as an expression
c:\program files\microsoft sdks\windows\v6.0a\include\windef.h(267) : see declaration of 'HDC'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(195) : error C2146: syntax error : missing ')' before identifier 'referenceHdc'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(195) : error C2761: '{ctor}' : member function redeclaration not allowed
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(198) : error C2059: syntax error : ')'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(199) : error C2143: syntax error : missing ';' before '{'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(199) : error C2447: '{' : missing function header (old-style formal list?)
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(211) : error C2065: 'IStream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(211) : error C2065: 'stream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(212) : error C2275: 'HDC' : illegal use of this type as an expression
c:\program files\microsoft sdks\windows\v6.0a\include\windef.h(267) : see declaration of 'HDC'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(212) : error C2146: syntax error : missing ')' before identifier 'referenceHdc'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(212) : error C2761: '{ctor}' : member function redeclaration not allowed
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(217) : error C2059: syntax error : ')'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(218) : error C2143: syntax error : missing ';' before '{'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(218) : error C2447: '{' : missing function header (old-style formal list?)
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(230) : error C2065: 'IStream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(230) : error C2065: 'stream' : undeclared identifier
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(231) : error C2275: 'HDC' : illegal use of this type as an expression
c:\program files\microsoft sdks\windows\v6.0a\include\windef.h(267) : see declaration of 'HDC'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(231) : error C2146: syntax error : missing ')' before identifier 'referenceHdc'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(231) : error C2761: '{ctor}' : member function redeclaration not allowed
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(236) : error C2059: syntax error : ')'
c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusmetafile.h(236) : fatal error C1003: error count exceeds 100; stopping compilation


Anyone know why?

Which compiler and show some code.

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2440: 'initializing' : cannot convert from 'const char [37]' to 'int'

A declaration is missing. Read the documentation. Does gdiplusimaging.h depend on you #include'ing something else?

#define UNICODE
#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;

VOID OnPaint(HDC hdc)
{
Graphics graphics(hdc);
Pen pen(Color(255, 0, 0, 255));
graphics.DrawLine(&pen, 0, 0, 200, 100);
}

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow)
{
HWND hWnd;
MSG msg;
WNDCLASS wndClass;
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;

// Initialize GDI+.
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = TEXT("GettingStarted");

RegisterClass(&wndClass);

hWnd = CreateWindow(
TEXT("GettingStarted"), // window class name
TEXT("Getting Started"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL); // creation parameters

ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);

while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

GdiplusShutdown(gdiplusToken);
return msg.wParam;
} // WinMain

LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;

switch(message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
OnPaint(hdc);
EndPaint(hWnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
} // WndProc

Thats the example code from MSDN. and i'm using visual C++ 2008 express.

Strange, that should work altough you need to link to the GDI+ lib. Try placing the following line above the UNICODE declaration and Rebuild Solution instead of Debug or Build Solution:
#pragma comment (lib, "gdiplus.lib")

Sweet! it worked thanks! by the way, this might be a dumb question but what does that line do?

It tells the linker to look in the library file for the function definition when linking the object files. But regardless, I think your problem was Rebuild All since MSVC++ builds incrementally and an object file doesn't tell the compiler anything. :)

Oh ok.

well thanks

i just saw this awesome smile............. :flame: