【问题标题】:_segment not defined wile migrate from VC6 to VS2019从 VC6 迁移到 VS2019 时未定义 _segment
【发布时间】:2021-09-10 08:40:51
【问题描述】:

我正在将一个 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];        /*          */

【问题讨论】:

    标签: visual-studio visual-c++ compiler-errors


    【解决方案1】:

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

    Microsoft C 版本 6.0 首次引入了以下关键字:

    _based
    _segment

    [...]

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

    【讨论】:

    • VS2019中有关键字对应吗?如果没有,我可以用什么替换 _segment?谢谢!
    • @David 没有对应的关键字,因为现在 32 位和 64 位使用的平面内存模型中不再有任何“segments”可言。 VC++ 仍然支持based pointers,尽管它们有相当特殊的用途。如果不完全了解旧代码首先在做什么,就无法回答完全重写与完全删除使用 _segment 寻址的 16 位代码是否更有意义。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-02
    • 2021-03-23
    • 1970-01-01
    • 1970-01-01
    • 2019-08-11
    • 2011-03-22
    相关资源
    最近更新 更多