Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have been trying to correct all compilation errors in my codes. After I got and impemente the very good counsels I got here[^] where I had pste the last cmpilati errrs.

The new errr is this:



1>shell.c
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\yvals_core.h(28): STL1003: Unexpected compiler, expected C++ compiler.
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\yvals_core.h(29,1): fatal error C1189: #error: Error in C++ Standard Library usage
1>sqlite3.c
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\yvals_core.h(28): STL1003: Unexpected compiler, expected C++ compiler.
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\yvals_core.h(29,1): fatal error C1189: #error: Error in C++ Standard Library usage


Checks n the intenet shows that it may be related to an improper use of a macro. What cuold be the solutin?

By the way, I am using visual studio 2022.

The following informationn could be relevant: it appears from the error message that the error may be conected to my inclusion of an #include "stdAfx.h" to shell.c and sqlite3.c which are c files for sqlite3 embedded database. Is it wrong to #include "stdAfx.h" to C files. My experience in the past has been that visual compels one to add stdafx.h to to every non-heaer files. Are c fies excluded?

I removed the stdafx.h header file and ended up with the following errors:


1>shell.c
1>C:\Users\HP\source\repos\ResultSheets\shell.c(28617,1): error C2857: '#include' statement specified with the /Ycstdafx.h command-line option was not found in the source file
1>sqlite3.c
1>C:\Users\HP\source\repos\ResultSheets\sqlite3.c(250817,1): error C2857: '#include' statement specified with the /Ycstdafx.h command-line option was not found in the source file



Th content of my heder file is s show below.


C++
#pragma once
#define _X86_

#define NOMINMAX  // this removes the min and max definitions

#include <SDKDDKVer.h>
#include <Windows.h>

#include <Commctrl.h>
#include <tchar.h>
#include <stringapiset.h>
#include <string.h>
#include <cstdio>
#include <stdarg.h>
#include <cstdlib>
// various windows and C RTL headers go here

#define _USE_MATH_DEFINES	// get PI, e, etc. definitions
#include <math.h>

#pragma warning( push )
#pragma warning( disable : 4458 )
#include <gdiplus.h>
#include <gdiplusheaders.h>
#pragma warning( pop )

#include <memory>
#include <exception>
#include <stdexcept>
#include <fstream>
#include <filesystem>

#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>


// other STL headers here



#include "resource.h"


What I have tried:

I have spent time reaing up the errr code after google searches.
Posted
Updated 31-Dec-23 10:50am
v6

stdAfx.h is a C++ header - it contains code which isn't understood by a C compiler because it isn;t party of the C language. C++ is a superset of C, not the other way around!

You can't include C++ headers in C code - it won't work. You would have to write your app in C++ to use any features of C++!
 
Share this answer
 
You have removed the stdafx.h file from your build, but you are telling the system to use it to create the precompiled headers.

However, it looks like you have modified the source of shell.c and/or sqlite3.c to include C++ headers. Making such changes will most likely mean that it will not build. You should use the original source files to build the distribution. You can then link the dll into your own application.

[edit]
You do not need to explicitly include gdiplusheaders.h as it is automatically included by gdiplus.h. I also wonder whether you actually need all of the other includes that you are using, as you seem to be mixing a lot of C and C++ code, much of which duplicates the others.
[/edit]
 
Share this answer
 
v2

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