Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (seongtaejeong at gmail.com)
홈페이지
첨부 파일
 

Visual C++ - error C1083: Cannot open include file: 'float.h': No such file or directory

"Platform Toolset"이 "Visual Studio 2017 - Windows XP (v141_xp)"로 설정된 Visual C++ 프로젝트를,

#include <iostream>

int main()
{
    std::cout << "Hello World!\n";
}

최근의 신규 Toolset으로 변경해 빌드하면 이런 오류가 발생합니다.

["Visual Studio 2017 (v141)"인 경우]
fatal error C1083: Cannot open include file: 'corecrt.h': No such file or directory

["Visual Studio 2019 (v142)" 또는 "Visual Studio 2022 (v143)"인 경우]
error C1083: Cannot open include file: 'float.h': No such file or directory

왜냐하면 "Platform Toolset"과 함께 "Windows SDK Version"도 변경해야 하기 때문입니다. 아마도 "v141_xp"인 경우 Windows SDK Version이 "7.0"으로 설정돼 있을 텐데요, 이것을 "10.0 (latest installed version)" 등으로 변경하면 됩니다.




XP용 빌드의 경우, "Windows.h"를 포함하면,

// Visual Studio 2022 + "Visual Studio 2017 - Windows XP (v141_xp)" + "Multi-threaded (/MT)" 설정으로 빌드

#include <iostream>
#include <Windows.h>

int main()
{
    std::cout << "Hello World!\n";
}

이런 컴파일 오류가 발생합니다.

error C2760: syntax error: unexpected token 'identifier', expected 'type specifier'

IUnknown을 사용하는 코드인데요,

extern "C++"
{
    template<typename T> void** IID_PPV_ARGS_Helper(T** pp) 
    {
        static_cast<IUnknown*>(*pp);    // make sure everyone derives from IUnknown
        return reinterpret_cast<void**>(pp);
    }
}

"Conformance mode"를 "No"로 설정하면 됩니다.

objbase.h error when compiling with /permissive- and v141_xp platform toolset
; https://developercommunity.visualstudio.com/t/objbaseh-error-when-compiling-with-permissive-and/174539

혹은, 헤더 파일 포함 전에 typedef로 명시해도 되는데요,

typedef struct IUnknown IUnknown;

#include <iostream>
#include <Windows.h>

그런데 재미있는 건, 저 코드가 어떤 C++ 표준과 관련이 있는 것인지 잘 모르겠습니다. 가령, 저 오류가 발생하는 코드를 유사하게 작성해서 재현해 보려고 했지만,

// Visual Studio 2022 + "Visual Studio 2017 - Windows XP (v141_xp)" + "Multi-threaded (/MT)" 설정으로 빌드

#define DECLSPEC_NOVTABLE_X __declspec(novtable)
#define DECLSPEC_UUID_X(x) __declspec(uuid(x))
#define MIDL_INTERFACE_X(x)   struct DECLSPEC_UUID_X(x) DECLSPEC_NOVTABLE_X
#define EXTERN_C    extern "C"

#ifndef DEFINE_GUID
typedef struct _GUID {
    unsigned long  Data1;
    unsigned short Data2;
    unsigned short Data3;
    unsigned char  Data4[8];
} GUID;
#endif

typedef GUID IID;

EXTERN_C const IID IID_IUnknown2;
extern "C++"
{
    MIDL_INTERFACE_X("F0FF0FF1-3E61-49FA-AF56-AEA18F4D74B7")
        IUnknown2
    {
    public:
        virtual void Release(void) = 0;
    };
}

MIDL_INTERFACE_X("0AEF294D-14E9-4ED1-BAF0-8609F6B3D157")
Test : public IUnknown2
{
    virtual void Release(void) = 0;
};

template<typename T> void** TEST_Helper(T** pp)
{
    static_cast<IUnknown2*>(*pp);
    return reinterpret_cast<void**>(pp);
}

#define IID_PPV_TEST(ppType) __uuidof(**(ppType)), TEST_Helper(ppType)

int main()
{
    Test* t;

    IID_PPV_TEST(&t);
}

컴파일이 잘됩니다. ^^; 혹시 저 문제의 C++ 표준이 무엇인지 아시는 분은 덧글 부탁드립니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 8/27/2024]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 



2024-09-03 11시19분
호오 신기하네요 .한번 추적해볼까
JunSeo Lee
2024-09-03 06시53분
호오 기대되네요. ^^
정성태

... 46  47  48  49  [50]  51  52  53  54  55  56  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12685정성태6/21/202118127Java: 21. Azure Web App Service에 배포된 Java 프로세스의 메모리 및 힙(Heap) 덤프 뜨는 방법
12684정성태6/19/202116473오류 유형: 728. Visual Studio 2022부터 DTE.get_Properties 속성 접근 시 System.MissingMethodException 예외 발생
12683정성태6/18/202117796VS.NET IDE: 166. Visual Studio 2022 - Windows Forms 프로젝트의 x86 DLL 컨트롤이 Designer에서 오류가 발생하는 문제 [1]파일 다운로드1
12682정성태6/18/202114326VS.NET IDE: 165. Visual Studio 2022를 위한 Extension 마이그레이션
12681정성태6/18/202114593오류 유형: 727. .NET 2.0 ~ 3.5 + x64 환경에서 System.EnterpriseServices 참조 시 CS8012 경고
12680정성태6/18/202116667오류 유형: 726. python2.7.exe 실행 시 0xc000007b 오류
12679정성태6/18/202116796COM 개체 관련: 23. CoInitializeSecurity의 전역 설정을 재정의하는 CoSetProxyBlanket 함수 사용법파일 다운로드1
12678정성태6/17/202115293.NET Framework: 1072. C# - CoCreateInstance 관련 Inteop 오류 정리파일 다운로드1
12677정성태6/17/202118069VC++: 144. 역공학을 통한 lxssmanager.dll의 ILxssSession 사용법 분석파일 다운로드1
12676정성태6/16/202117250VC++: 143. ionescu007/lxss github repo에 공개된 lxssmanager.dll의 CLSID_LxssUserSession/IID_ILxssSession 사용법파일 다운로드1
12675정성태6/16/202115148Java: 20. maven package 명령어 결과물로 (war가 아닌) jar 생성 방법
12674정성태6/15/202116401VC++: 142. DEFINE_GUID 사용법
12673정성태6/15/202116995Java: 19. IntelliJ - 자바(Java)로 만드는 Web App을 Tomcat에서 실행하는 방법
12672정성태6/15/202118611오류 유형: 725. IntelliJ에서 Java webapp 실행 시 "Address localhost:1099 is already in use" 오류
12671정성태6/15/202127277오류 유형: 724. Tomcat 실행 시 Failed to initialize connector [Connector[HTTP/1.1-8080]] 오류
12670정성태6/13/202117254.NET Framework: 1071. DLL Surrogate를 이용한 Out-of-process COM 개체에서의 CoInitializeSecurity 문제파일 다운로드1
12669정성태6/11/202117454.NET Framework: 1070. 사용자 정의 GetHashCode 메서드 구현은 C# 9.0의 record 또는 리팩터링에 맡기세요.
12668정성태6/11/202119946.NET Framework: 1069. C# - DLL Surrogate를 이용한 Out-of-process COM 개체 제작파일 다운로드2
12667정성태6/10/202117750.NET Framework: 1068. COM+ 서버 응용 프로그램을 이용해 CoInitializeSecurity 제약 해결파일 다운로드1
12666정성태6/10/202115394.NET Framework: 1067. 별도 DLL에 포함된 타입을 STAThread Main 메서드에서 사용하는 경우 CoInitializeSecurity 자동 호출파일 다운로드1
12665정성태6/9/202117450.NET Framework: 1066. Wslhub.Sdk 사용으로 알아보는 CoInitializeSecurity 사용 제약파일 다운로드1
12664정성태6/9/202115227오류 유형: 723. COM+ PIA 참조 시 "This operation failed because the QueryInterface call on the COM component" 오류
12663정성태6/9/202117641.NET Framework: 1065. Windows Forms - 속성 창의 디자인 설정 지원: 문자열 목록 내에서 항목을 선택하는 TypeConverter 제작파일 다운로드1
12662정성태6/8/202115393.NET Framework: 1064. C# COM 개체를 PIA(Primary Interop Assembly)로써 "Embed Interop Types" 참조하는 방법파일 다운로드1
12661정성태6/4/202127389.NET Framework: 1063. C# - MQTT를 이용한 클라이언트/서버(Broker) 통신 예제 [4]파일 다운로드1
12660정성태6/3/202118096.NET Framework: 1062. Windows Forms - 폼 내에서 발생하는 마우스 이벤트를 자식 컨트롤 영역에 상관없이 수신하는 방법 [1]파일 다운로드1
... 46  47  48  49  [50]  51  52  53  54  55  56  57  58  59  60  ...