3

I'm having header-related issues apparently new to VS2015 while trying to compile DOSBox SVN Daum in Windows 10. Examples:

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  

My search tells me this sort of problem has been happening to projects around, but I couldn't get it fixed.

In particular, I read VisualStudio 2015 RC Issue with Includes and https://blogs.msdn.microsoft.com/vcblog/2015/03/03/introducing-the-universal-crt/ , and then changed the contents of AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props to:

<?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>

No luck though. :(

Images:

VC++ Directories VC++ standard-header-related compilation errors

I'm far from being an experienced C programmer. Can anyone please tell me what's missing? Thanks!

Community
  • 1
  • 1

1 Answers1

2

I had the same issue with a different program and after looking at the includes, I finally solved it.

If you look at a typical cstdint from a recent Visual Studio, you'll notice one include is stdint.h. This is where the actual definitions for the various types exist. What cstdint does is export the definitions to be members of the std namespace.

However, it appears here that while the first lines with intXX_t compiled fine, the int_least_xx_t don't. This is because it reads the wrong stdint.h file, that doesn't have some of the definitions needed. That file was written by people who wanted to use the named sizes before MSVC supported them (they came with C99, that MSVC never really got around to support, then in C++11, which at that point MSVC offered support for).

As they only needed the exact types, they didn't write the defines for the other types. Now that MSVC supports it, there is no need for this compatibility file. However, because the projects files were not updated, the compiler will find the bad compatibility header instead of the correct one, which leads to this error.

There are two ways to solve this: change the include folder order so that it will get the one you want, or delete the bad stdint.h file. It is easy to find as you can use Visual Studio to open #include files. For your case, the file is in the src/platform/visualc/ directory.

Addendum: this is my faulty stdint.h file

#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;
meneldal
  • 1,609
  • 1
  • 15
  • 29