Quel est le bon ordre pour ordonner les fichiers d’en-tête suivants dans une application C++ ?

la programmation

[ad_1]

Mon application a généré les erreurs de compilation suivantes. Les erreurs montrent que le problème vient de la disposition de mes fichiers d’en-tête. S’il vous plaît, quelle est la bonne façon d’organiser les fichiers d’en-tête dans mon application en tenant compte des messages d’erreur suivants. Veuillez noter que je n’ai inclus aucun des fichiers d’en-tête affichés dans mon application. Ils doivent être inclus dans un ou plusieurs des fichiers d’en-tête principaux que j’ai inclus dans ma candidature. Je crois que les en-têtes conflictuels sont les suivants, situés dans winmain :

#include  <Windows.h>
#include  <gdiplus.h>
#include <Commctrl.h>

et

#include <Gdiplus.h>
#include <gdiplusheaders.h>
#include <string>

qui se trouve dans un autre fichier

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(203,14): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(975,25): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(983,25): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\wtypesbase.h(447,26): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\wtypesbase.h(472,26): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\wtypesbase.h(489,26): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\wtypes.h(85,26): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\wtypes.h(94,26): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\wtypes.h(100,26): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\wtypes.h(106,26): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\wtypes.h(112,26): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\wtypes.h(118,26): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\wtypes.h(493,26): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidlbase.h(2275,79): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidlbase.h(2289,62): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidlbase.h(8492,79): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidlbase.h(8508,62): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(10444,69): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(11002,77): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(11034,77): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(11542,79): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(11557,62): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(12018,26): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(13832,62): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(13847,62): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(15586,79): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(15602,62): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(15749,77): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(15788,77): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(15805,79): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(15822,62): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(16067,62): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\objidl.h(16086,62): error C2872: 'byte': ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\rpcndr.h(202,23): message : could be 'unsigned char byte'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstddef(29,24): message : or       'std::byte'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\oaidl.h(571,26): error C2872: 'byte': ambiguous symbol

Ce que j’ai essayé :

J’essaie de résoudre le problème depuis hier. Je ne pense pas que Google puisse vous aider à résoudre ce problème.

Solution 1

J’ai trouvé que le fichier d’en-tête gdiplus.h était un peu problématique. Je l’utilise presque toujours dans un fichier d’en-tête précompilé et il ressemble généralement à ceci :

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

#include <SDKDDKVer.h>

// 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>
#pragma warning( pop )

#include <vector>
#include <string>
#include <algorithm>

// other STL headers here

Avec mon code, j’utilise toujours le niveau d’avertissement 4 et le pragma désactive l’avertissement 4458 qui résulte généralement des en-têtes GDI+. J’inclus gdiplus.h avant les en-têtes STL et après les en-têtes Windows et RTL.

Une autre chose : je n’ai jamais mis de using namespace instruction dans un fichier d’en-tête. Ils ne peuvent pas être annulés et causent généralement des problèmes.

Solution 2

On dirait que tu as

C++
using namespace std;

quelque part avant les inclusions

[ad_2]

コメント

Titre et URL copiés