首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

MK_FP宏定义解决思路

2013-12-28 
MK_FP宏定义#define MK_FP(seg,ofs) ((void __seg *)(seg) + (void __near *)(ofs))我在网上看到说MK_FP()

MK_FP宏定义
#define MK_FP(seg,ofs) ((void __seg *)(seg) + (void __near *)(ofs))
我在网上看到说MK_FP()这个宏的功能是设置一个远指针,可我看不懂((void __seg *)(seg) + (void __near *)(ofs))这是啥意思?__seg和__near又代表的是啥意思啊??希望各位帮帮忙,再此谢谢大家了
[解决办法]
别管 替换过去就明白了
[解决办法]
TC或BC中,在不明白的符号上按Ctrl+F1键。
  _seg, __seg (keyword)

Use _seg in segment pointer type declarators.

 Syntax:
   <datatype> _seg *<identifier> ;
   <datatype> __seg *<identifier> ;

Any indirection through <identifier> has an assumed offset of 0.

In arithmetic involving segment pointers, the following rules hold true:

1. You can't use the ++, --, +=, or -= operators with segment pointers.

2. You can't subtract one segment pointer from another.

3. When you're adding a near pointer to a segment pointer, the operation
creates a far pointer result by using the segment from the segment pointer
and the offset from the near pointer.

Therefore, the two pointers must either point to the same type, or one must
be a pointer to void.

There is no multiplication of the offset, regardless of the type pointed to.

4. When you're adding or subtracting an integer operand to or from a segment
pointer, the result is a far pointer. The segment is taken from the segment
pointer; the offset is calculated by multiplying the size of the object
pointed to by the integer operand.

5. Segment pointers can be assigned, initialized, passed into and out of
functions, compared and so on.

In other words, other than the mentioned restrictions, they are treated
exactly like any other pointer.


  near, _near, __near (type modifier)

Forces pointers to be near; generates function code for a near call and a
near return.

 Syntax:
   <type> near <pointer definition> ;
   <type> near <function definition>
   <type> _near <pointer definition> ;
   <type> _near <function definition>
   <type> __near <pointer definition> ;
   <type> __near <function definition>

The first version of near declares a pointer to be one word with a range of
64K.

This type modifier is usually used when compiling in the medium, large, or
huge memory models to force pointers to be near.

 Example:
  char near *s;
  int (near *ip)[10];

When near is used with a function declaration, Borland C++ generates
function code for a near call and a near return.

 Example:
  int near my_func() {}


 Example:
  int _seg *name;

热点排行