¿Cuál es el orden correcto para ordenar los siguientes archivos de encabezado en una aplicación C++?

programación

[ad_1]

Mi aplicación salió con los siguientes errores de compilación. Los errores muestran que el problema es la disposición de mis archivos de encabezado. Por favor, ¿cuál es la forma correcta de organizar los archivos de encabezado en mi aplicación teniendo en cuenta los siguientes mensajes de error? Tenga en cuenta que no incluí ninguno de los archivos de encabezado mostrados en mi aplicación. Deben estar incluidos en uno o más de los archivos de encabezado principales que he incluido en mi solicitud. Creo que los encabezados en conflicto son los siguientes ubicados en winmain:

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

y

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

que se encuentra en otro archivo

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

Lo que he probado:

Llevo desde ayer intentando solucionar el problema. No creo que Google pueda ayudar con este problema.

Solución 1

He encontrado que el archivo de encabezado gdiplus.h es un poco problemático. Casi siempre lo uso en un archivo de encabezado precompilado y normalmente tiene este aspecto:

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

Con mi código siempre uso el nivel de advertencia 4 y pragma desactiva la advertencia 4458 que generalmente resulta de los encabezados GDI+. Incluyo gdiplus.h antes de los encabezados STL y después de los encabezados de Windows y RTL.

Otra cosa: nunca, nunca puse un using namespace declaración en un archivo de encabezado. No se pueden deshacer y suelen causar problemas.

[ad_2]

コメント

Título y URL copiados