Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am the person that posted the question here [^]

After numerous hours of trying to reduce the compiler errors to zero, I have finally come to the conclusion that the problem is either with my copy of Visual Studio 2022 or it's a compile settings problem.

After solving a troubling #error compilation error problem, my program will still not compile with Gdiplus elements present.

Somebody wondered if it is the same code I posted online that
I was referring to because he could not understand why I complained that my code did not compile while it effortlessly compiled on his computer.

Finally, I took the bull by the horn. I created an entire new project and compiled it. It compiled and ran. Then I added the troubling Gdiplus elements to it. The new code that has not been tainted by any code of mine in any way, did not run on adding the Gdiplus elements. I finally came to the conclusion that there is something wrong with my copy of Visual Studio or the default compiler settings would not work with gdiplus.

The strangest thing is that the program acts as if it could not see the <gdiplus.h> header. It won't recognise any of the classes and structures in that file. As far as it is concerned, the file does not exist.

To resolve the problem, I made the directory in which the file (gdiplus.h) is located an additional include dirctory for my project, yet no difference. Finally, I copied the file from its location and put the copy in my application's directory, yet no solution.

I would greatly appreciate it if anyone can help with a solution. I have spent too many hours on this compilation error, not counting those I spent on Google because of it.
If it is a compiler setting problem, I will like to know the correct compiler setting.
Shown below is the Visual Studio's compiler output. A close look will reveal that the program does not recognise gdiplus classes. They seem not to exist.

This is the problematic code:
C++
#include "framework.h"
#include <gdiplus.h>

using namespace Gdiplus;
//#pragma comment (lib,"Gdiplus.lib")

//Some normal declarations go here
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPWSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // TODO: Place code here.
    GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR gdiplusToken;
    GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

    //Some  normal windows code goes here

    GdiplusShutdown(gdiplusToken);

    return (int) msg.wParam;
}


Thsis the content of framework.h:

C++
// header.h : include file for standard system include files,
// or project specific include files
//

#pragma once

#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <windows.h>
// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>


Build started...
1>------ Build started: Project: ResultSheets, Configuration: Debug x64 ------
1>CppSQLite3.cpp
1>C:\Users\HP\source\repos\ResultSheets\CppSQLite3.cpp(1066,61): warning C4244: 'argument': conversion from 'const __int64' to 'int', possible loss of data
1>ResultSheets.cpp
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusImaging.h(84,16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusImaging.h(84,15): error C2440: 'initializing': cannot convert from 'const char [37]' to 'int'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusImaging.h(84,15): message : There is no context in which this conversion is possible
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusImaging.h(85,1): error C2146: syntax error: missing ';' before identifier 'IImageBytes'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusImaging.h(85,15): error C2059: syntax error: 'public'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusImaging.h(86,1): error C2143: syntax error: missing ';' before '{'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusImaging.h(86,1): error C2447: '{': missing function header (old-style formal list?)
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusImaging.h(291,13): error C3646: 'id': unknown override specifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusImaging.h(291,15): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(397,12): error C2061: syntax error: identifier 'IStream'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(407,12): error C2061: syntax error: identifier 'IStream'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(417,20): error C2061: syntax error: identifier 'IStream'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(455,34): error C2061: syntax error: identifier 'PROPID'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(456,33): error C2061: syntax error: identifier 'PROPID'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(457,31): error C2061: syntax error: identifier 'PROPID'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(465,34): error C2061: syntax error: identifier 'PROPID'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(483,5): error C2535: 'Gdiplus::Image::Image(void)': member function already defined or declared
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(396,5): message : see declaration of 'Gdiplus::Image::Image'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(519,12): error C2061: syntax error: identifier 'IStream'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(529,12): error C2061: syntax error: identifier 'IStream'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(773,17): error C2061: syntax error: identifier 'IStream'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(829,12): error C2061: syntax error: identifier 'IStream'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(828,5): error C2535: 'Gdiplus::Metafile::Metafile(void)': member function already defined or declared
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(773,5): message : see declaration of 'Gdiplus::Metafile::Metafile'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(836,12): error C2061: syntax error: identifier 'IStream'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(835,5): error C2535: 'Gdiplus::Metafile::Metafile(void)': member function already defined or declared
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(773,5): message : see declaration of 'Gdiplus::Metafile::Metafile'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(845,12): error C2061: syntax error: identifier 'IStream'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(844,5): error C2535: 'Gdiplus::Metafile::Metafile(void)': member function already defined or declared
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(773,5): message : see declaration of 'Gdiplus::Metafile::Metafile'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(870,12): error C2061: syntax error: identifier 'IStream'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(938,5): error C2535: 'Gdiplus::Metafile::Metafile(void)': member function already defined or declared
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusHeaders.h(773,5): message : see declaration of 'Gdiplus::Metafile::Metafile'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1145,32): warning C4229: anachronism used: modifiers on data are ignored
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1145,25): error C2065: 'IStream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1145,34): error C2065: 'stream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1145,52): error C2065: 'image': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1145,42): error C2275: 'Gdiplus::GpImage': expected an expression instead of a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1151,35): warning C4229: anachronism used: modifiers on data are ignored
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1151,28): error C2065: 'IStream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1151,37): error C2065: 'stream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1151,55): error C2065: 'image': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1151,45): error C2275: 'Gdiplus::GpImage': expected an expression instead of a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1168,39): error C2061: syntax error: identifier 'IStream'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1256,59): error C2061: syntax error: identifier 'PROPID'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1259,41): error C2061: syntax error: identifier 'PROPID'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1262,37): error C2061: syntax error: identifier 'PROPID'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1274,40): error C2061: syntax error: identifier 'PROPID'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1298,35): warning C4229: anachronism used: modifiers on data are ignored
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1298,28): error C2065: 'IStream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1298,37): error C2065: 'stream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1298,56): error C2065: 'bitmap': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1298,45): error C2275: 'Gdiplus::GpBitmap': expected an expression instead of a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1304,38): warning C4229: anachronism used: modifiers on data are ignored
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1304,31): error C2065: 'IStream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1304,40): error C2065: 'stream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1304,59): error C2065: 'bitmap': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(1304,48): error C2275: 'Gdiplus::GpBitmap': expected an expression instead of a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2235,13): warning C4229: anachronism used: modifiers on data are ignored
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2235,5): error C2065: 'IStream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2235,25): error C2065: 'stream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2236,25): error C2065: 'header': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2236,5): error C2275: 'Gdiplus::MetafileHeader': expected an expression instead of a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2255,24): error C2061: syntax error: identifier 'IStream'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2275,38): warning C4229: anachronism used: modifiers on data are ignored
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2275,30): error C2065: 'IStream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2275,40): error C2065: 'stream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2275,61): error C2065: 'metafile': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2275,48): error C2275: 'Gdiplus::GpMetafile': expected an expression instead of a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2322,13): warning C4229: anachronism used: modifiers on data are ignored
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2322,5): error C2065: 'IStream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2322,25): error C2065: 'stream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2323,5): error C2275: 'HDC': expected an expression instead of a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2323,25): error C2146: syntax error: missing ')' before identifier 'referenceHdc'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2333,13): warning C4229: anachronism used: modifiers on data are ignored
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2333,5): error C2065: 'IStream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2333,25): error C2065: 'stream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2334,5): error C2275: 'HDC': expected an expression instead of a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusFlat.h(2334,25): error C2146: syntax error: missing ')' before identifier 'referenceHdc'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusPath.h(145,35): error C2061: syntax error: identifier 'byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(80,11): error C7550: 'Gdiplus::Metafile::{ctor}': the qualified name in this context names a constructor, not a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(80,23): error C2065: 'IStream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(80,32): error C2065: 'stream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(81,1): error C2143: syntax error: missing ';' before '{'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(81,1): error C2447: '{': missing function header (old-style formal list?)
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(198,11): error C7550: 'Gdiplus::Metafile::{ctor}': the qualified name in this context names a constructor, not a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(199,8): error C2065: 'IStream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(199,28): error C2065: 'stream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(200,8): error C2275: 'HDC': expected an expression instead of a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(200,28): error C2146: syntax error: missing ')' before identifier 'referenceHdc'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(204,1): error C2143: syntax error: missing ';' before '{'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(204,1): error C2447: '{': missing function header (old-style formal list?)
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(215,11): error C7550: 'Gdiplus::Metafile::{ctor}': the qualified name in this context names a constructor, not a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(216,8): error C2065: 'IStream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(216,28): error C2065: 'stream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(217,8): error C2275: 'HDC': expected an expression instead of a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(217,28): error C2146: syntax error: missing ')' before identifier 'referenceHdc'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(223,1): error C2143: syntax error: missing ';' before '{'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(223,1): error C2447: '{': missing function header (old-style formal list?)
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(234,11): error C7550: 'Gdiplus::Metafile::{ctor}': the qualified name in this context names a constructor, not a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(235,8): error C2065: 'IStream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(235,28): error C2065: 'stream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(236,8): error C2275: 'HDC': expected an expression instead of a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(236,28): error C2146: syntax error: missing ')' before identifier 'referenceHdc'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(242,1): error C2143: syntax error: missing ';' before '{'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(242,1): error C2447: '{': missing function header (old-style formal list?)
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(284,16): error C2761: 'GetMetafileHeader': redeclaration of member is not allowed
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(284,8): error C2065: 'IStream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(284,28): error C2065: 'stream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(285,28): error C2065: 'header': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(285,9): error C2275: 'Gdiplus::MetafileHeader': expected an expression instead of a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(287,1): error C2143: syntax error: missing ';' before '{'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusMetafile.h(287,1): error C2447: '{': missing function header (old-style formal list?)
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusBitmap.h(49,8): error C7550: 'Gdiplus::Image::{ctor}': the qualified name in this context names a constructor, not a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusBitmap.h(50,8): error C2065: 'IStream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusBitmap.h(50,17): error C2065: 'stream': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusBitmap.h(51,8): error C2275: 'BOOL': expected an expression instead of a type
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusBitmap.h(52,5): fatal  error C1003: error count exceeds 100; stopping compilation
1>Generating Code...
1>Done building project "ResultSheets.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 4:30 PM and took 29.429 seconds ==========


What I have tried:

I have spent hours Googling and trying several approaches to resolve the issue.
Posted
Updated 24-Oct-23 10:25am
v6
Comments
Rick York 22-Oct-23 17:25pm    
Show us the include statements you are using. I think that is where the problem is. I use just the default include paths plus my own libraries and there are no problems. I include gdiplus.h in a precompiled header.
Richard MacCutchan 23-Oct-23 5:02am    
Show us the actual code that causes the problem. We cannot guess from the error messages, although it does look like you are probably missing, or mis-placing, one or more header files. And I can guarantee this has nothing to do with Visual Studio 2022 (especiall as it is not a compiler), or the C++ compiler and Linker. I have many programs that use GDI+ that are built using that system.
Gbenbam 24-Oct-23 2:35am    
! have added code. I will really appreciate it if you can help.
Richard MacCutchan 24-Oct-23 4:19am    
That is the same as your original question on this matter, and as before it compiles fine if I replace the #include "framework.h" with #include <windows.h>. So you need to show the contents of the framework.h header file. Please ensure you provide all relevant information, as we cannot see your screen, or read your mind.
Gbenbam 24-Oct-23 6:32am    
So, is there any assistance you can give with these revelation?

As I suggested last time, go back to basics. Start here: Using GDI+ - Win32 apps | Microsoft Learn[^] and get a brand new, empty project up and running - then slowly add your existing code until it either fails, or works. Though I suspect from your error list that you didn't write it, and have no idea how it is supposed to be built, much less how it works ... so that's probably going to be difficult for you.
 
Share this answer
 
Comments
Gbenbam 22-Oct-23 12:42pm    
Do kindly help me understand what you are trying to tell me. I have not used any GDI+ class or function in my project. Not even a single tiny one. All though I would use them a lot much more later. This is a new project, I just wanted to ensure that it is ready for GDI+ operations. All I have done so far is to call GdiplusStartup in WinMain when the program starts and call GdiplusShutdown when it is about to exit. So, for now, I have not really carried out any GDI+ operation.Thanks for the link.I will check it out.
Gbenbam 22-Oct-23 12:50pm    
I checked out the link, that link is about showing people how to use GDI+ classes. The problem here for now is how to ensure the program is able to use GDI+ classes. How can a program, that did not even compilein the first place, use GDI+ classes. The hudle I am trying to scale at this stage it to get the program to initialize itself succeccessfully for GDI+ operation first. The program is yet to do that. GdiplusStartup will not compile, not to even talk using any class or structure.
OriginalGriff 22-Oct-23 13:46pm    
And if you follow what the link is telling you to do, and do it as it tells you, you will end up with a nice simple app that uses GDI+.

You can then rip out all the stuff that uses it to draw stuff you don't need, and carefully add your project code back into that. What do you think you end up with?
Gbenbam 24-Oct-23 2:38am    
The example codes in your link use stdafx.h. I don't know how to make visual studio add stdafx.h in visual studio 2022. If you knw ho it is done kindly tell me.
Gbenbam 23-Oct-23 10:13am    
Ok. I will give ita try and feed you back.
The first errors are these :
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusImaging.h(84,16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusImaging.h(84,15): error C2440: 'initializing': cannot convert from 'const char [37]' to 'int'
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\GdiplusImaging.h(84,15): message : There is no context in which this conversion is possible
line 84 of GdiplusImaging.h has this :
C++
MIDL_INTERFACE("025D1823-6C7D-447B-BBDB-A3CBC3DFA2FC")
That indicates MIDL_INTERFACE was not defined. It resolves to __declspec(uuid(x)) which is defined in WinNT.h. This indicates you included GDIplus.h before Windows.h. It needs to come after the windows include files which in my programs are AfxWin.h and its relatives since I use GDIplus only in MFC-based programs.

ETA: you can find these things out with the editor in Visual Studio. I went to my precompiled header file, right-clicked on GDIplus.h where I included it, and selected "Go to document gdiplus.h" which opened it in the editor. I did the same for GDIplusImaging.h and opened it. Then I went to line 84, right-clicked on MIDL_INTERFACE, and selected go to definition. By doing this back-tracking you can find out what is causing problems for you.
 
Share this answer
 
v2
Comments
Gbenbam 23-Oct-23 10:26am    
I had replied previouly without reading your solution very closely. I always put #include<gdiplus.h> after windows.h. Same goes for using namespace gdiplus and
#pragma comment(lib,"Gdiplus.lib"). Unless what you really meant was to put is before windows.h. That is, above it, in my program. I had experimented with putting gdiplus.h before windows.h to no effect.By the way, how can I make visual studio add stdafx.h to my program. I selected the link option for using it, but it did not use it. I created an header file with that name and included it, but nothing came out of it.Instead it was asking for pc.h or something like that.
The solution I have found so far is to replace framework.h with windows.h. This made the program to compile. However, since it was visual studio that generated framework.h whose content is shown above, it remains to be seen what disadvantage exists from replacing a visual studio generated framwork.h with windows.h. My initial assertion has been proved to be valid. The problem ws never with me. The problem was with visual studio that placed header files in framework.h in such a way that they clash with gdiplus.h. No matter where you place it, for as long as framework.h exists in your program, it with clash with gidipus.h. I had experimented placing gdiplus.h in differnt positions in relations to framework.h, but it never resolved the compilation problem. I tried placiing it above, but it never worked. Naturally, I always place my header files below visual studio generated header files, so the normal action on my part was to initially place it below framework.h. That, too, never resolved the problem. I am now vindicated. The problem is with visual studio. Anyone who knows how to contact the developers should notify them that visual studio generated framework.h clashes with gdiplus.h.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900