从 VC6 迁移到 VS2019 时未定义 _segment

问题描述

我正在将一个 Windows 项目从 VC6 迁移到 VS2019,但出现错误

E0020 标识符“_segment”未定义

我试图找到 _segment 定义,但没有找到。所以,我想知道 _segment 是否可能是 VC6 中的关键字。但是,我仍然在 Google 中找不到任何东西。

知道如何修复错误吗?谢谢。

代码是:

#ifndef _MSC_Ver
#define _MSC_Ver
#endif

/* MS-C  ?? */
#ifdef  _MSC_VER
_segment SegDefine,SegType,SegSym,SegCode;
#endif

#define ALLOC_C
#include "common.h"
#include <malloc.h>
#include "extern.h"

#ifdef  MSDOS
#include <dos.h>
#ifndef __WATCOMC__
#include <memory.h>
#endif
#endif

/* MM(????)?    */
#define MaxClass    8

#ifdef  _MSC_VER    /* MS-C  ?? */

/* FARBased ? */
static USHORT       mmFarSeg[MaxClass];         /* ??         */
static USHORT       mmFarBase[MaxClass];        /*          */
static USHORT       mmFarOrg[MaxClass];         /* ??        */
static USHORT       mmFarSize[MaxClass];        /*          */

解决方法

_segment 是 16 位 MSC 6 和 VC 1.x(不是 VC 6)中的关键字,与 x86 memory segmentation_based 指针相关.从 VC 2.0 开始,该关键字在 32 位版本的 VC 中已停用。来自微软的Q67882

以下关键字是在 Microsoft C 版本 6.0 中首次引入的:

_based
_segment

[...]

注意:在 Microsoft Visual C++ 32 位版本 2.0 版中,_segment 关键字 已删除,__based 关键字的功能已更改。