3

在尝试在 Windows 10 中编译 DOSBox SVN Daum 时,我遇到了与 VS2015 明显相关的标头相关问题。示例:

Severity    Code    Description Project File    Line    Suppression State
Error (active)      the global scope has no "int_least8_t"  dosbox  c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cstdint  23  
Error   C2039   'int_least8_t': is not a member of '`global namespace'' dosbox  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cstdint  23  

我的搜索告诉我这种问题已经发生在周围的项目中,但我无法修复它。

特别是,我阅读了 VisualStudio 2015 RC Issue with Includeshttps://blogs.msdn.microsoft.com/vcblog/2015/03/03/introducing-the-universal-crt/,然后更改了 AppData\Local 的内容\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props 到:

<?xml version="1.0" encoding="utf-8"?> 
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets">
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <IncludePath>D:\dev\include;$(UniversalCRT_IncludePath);$(IncludePath)</IncludePath>
    <LibraryPath>D:\dev\lib;$(UniversalCRT_LibraryPath_x86);$(LibraryPath)</LibraryPath>
  </PropertyGroup>
  <ItemDefinitionGroup />
  <ItemGroup />
</Project>

虽然没有运气。:(

图片:

VC++ 目录 VC++ 标准头相关的编译错误

我远不是一个有经验的 C 程序员。谁能告诉我缺少什么?谢谢!

4

1 回答 1

2

我在使用不同的程序时遇到了同样的问题,在查看了包含内容后,我终于解决了。

如果您查看cstdint最近的 Visual Studio 中的一个典型示例,您会注意到其中一个包含stdint.h. 这是存在各种类型的实际定义的地方。什么cstdint是将定义导出为std命名空间的成员。

但是,在这里看来,虽然第一行intXX_t编译得很好,int_least_xx_t但没有。这是因为它读取了错误的stdint.h文件,其中没有一些需要的定义。该文件是由想要在 MSVC 支持之前使用命名大小的人编写的(他们与 C99 一起提供,MSVC 从未真正得到支持,然后在 C++11 中,当时 MSVC 提供支持)。

因为他们只需要确切的类型,所以他们没有为其他类型编写定义。现在 MSVC 支持它,不需要这个兼容性文件。但是,由于项目文件没有更新,编译器会发现错误的兼容性头而不是正确的头,从而导致此错误。

有两种方法可以解决这个问题:更改包含文件夹的顺序以使其获得您想要的文件夹,或者删除坏stdint.h文件。它很容易找到,因为您可以使用 Visual Studio 打开#include文件。对于您的情况,该文件位于src/platform/visualc/目录中。

附录:这是我的错误stdint.h文件

#pragma once

/* a minimal set of C99 types for use with MSVC */

typedef signed char int8_t;
typedef short int int16_t;
typedef int int32_t;
typedef __int64 int64_t;

typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned __int64 uint64_t;
于 2019-07-18T07:37:00.557 回答