C/C++ÖÐnearºÍfarµÄÇø±ð
C/C++ÖÐnearºÍfarµÄÇø±ð
¹Ø¼ü×ÖnearºÍfarÊÜÄ¿±ê¼ÆËã»úÌåϵ½á¹¹µÄÓ°Ï졣Ŀǰ±à³ÌÖÐʹÓò»¶à¡£
near¹Ø¼ü×Ö´´½¨Ò»¸öÖ¸Ïò¿ÉÑ°Ö·ÄÚ´æµÍ¶Ë²¿·ÖµÄÄ¿±êÖ¸Õë¡£ÕâЩָÕëÕ¼ÓÃÄÚ´æµÄµ¥Ò»×Ö½Ú£¬²¢ÇÒËûÃÇÄܹ»Ö¸ÏòµÄÄÚ´æµ¥Ôª±»ÏÞÖƵ½256¸öλÖã¬Í¨³£ÊÇÔÚ0x0000~0x00ff·¶Î§ÖС£
int near * ptr£»
far¹Ø¼ü×Ö´´½¨Ò»¸öÄܹ»Ö¸ÏòÄÚ´æÖÐÈκÎÊý¾ÝµÄÖ¸Õ룺
char far * ptr£»
near (½ü)Ö¸Õ룺16λ¶ÎÄÚÆ«ÒƵØÖ·
far(Ô¶)Ö¸Õ룺16λ¶ÎµØÖ·£«16λ¶ÎÄÚÆ«ÒƵØÖ·
huge(¾Þ)Ö¸Õ룺32λ¹æ¸ñ»¯µÄ¾ßÓÐΨһÐÔµÄÄÚ´æµØÖ·
CÓïÑԵĴæÖüÊôÐÔÓÉÁùÖÖ±àÒëģʽ¾ö¶¨(²Î¼ûTC¼¯³É»·¾³²Ëµ¥ÖеÄoption->compiler->modelÑ¡Ïî)£¬Ä¬ÈϵıàÒëģʽΪsmall, ÔڸñàÒëģʽÏ£¬Ö¸ÕëµÄĬÈÏÊôÐÔΪnear¡£
²¹³ä£ºnearÖ¸ÕëÊÇ16λָÕ룬ÒÀÀµÒ»¸ö¶ÎµØÖ·¼Ä´æÆ÷£¬Ö¸Õë±äÁ¿¾ÍÊÇλÒÆÁ¿£¬ÀûÓà ¶ÎµØÖ·¼Ä´æÆ÷+Ö¸Õë À´Ñ°Ö·£¬ËùÒÔÓÐ64KÖ®ÏÞÖÆ¡£
far Ö¸ÕëÊÇ32λָÕ룬²»µ«ÓÐ16λµÄλÒÆÁ¿£¬»¹ÓÐ16λµÄ¶ÎµØÖ·£¬µ«´ËÖ¸ÕëÓиöȱÏÝ£¬ÔöÁ¿Ê±Ö»¼Óµ½Î»ÒƲ¿·Ö£¬Ò»µ©16λµÄλÒÆÁ¿³¬¹ýÁËFFFF¾Í»á»Øµ½Õâ¸ö¶ÎµØÖ·µÄ³õʼ¡£
ËùÒÔ£¬ÓÖÒýÈëÁËhugeÖ¸Õ룬hugeÖ¸ÕëÓëfarÒ»Ñù£¬ÆäÇø±ð½öÔÚÓÚʹÓÃÁ˱ê×¼»¯µÄ·½·¨À´±íʾ£¬ÕâÑùËùÓеĵØÖ·¶¼ÓÐÒ»¸öΨһµÄ±íʾ·½·¨£¬´Ó¶ø±ÜÃâÁËfarÖ¸ÕëµÄÎÊÌâ¡£
¿ÕÖ¸Õë¹æ¶¨ÁËÒ»ÖÖÖ¸Õë״̬£¬Èç¹ûûÓÐÕâ¸ö¿ÕÖ¸Õ룬¾ÍÈçÊý×ÖûÓÐÁË0¡£
Ïà¹ØÎĵµ£º
1.c++µÄµ½´¦º¯ÊýÖ»ÒªÔÚº¯ÊýÉêÃ÷µÄʱºò¼Ó¸öµ¼³ö¹Ø¼ü×־ͿÉÒÔÁË
2.²ÎÊýÀàÐÍÎÊÌâ,
Ò»°ãµÄc++ÖÐchar * ¶ÔÓ¦ c#ÖеÄstring
¶øc++ÖÐ char **ÀàÐ͵IJÎÊý¶ÔÓ¦c#ÖÐ ref string ÕâÖÖÒ»°ã¶¼ÊÇÓÃÀ´·µ»Ø×Ö·û´®µÄ!
3.º¯ÊýÈë¿ÚÎÊÌâ,Ò»°ã»á³öÏÖ "ÕÒ²»µ½Èë¿Úµã" Õâ¸öÎÊÌâ²»ÊÇÓÉÄãÒýÆðµÄ,¶øÊÇϵͳ×Ô¼º°ÑÃû×Ö¸ÄÁË,¸Ä³ÉʲôÑùµÄÃû×Ö½¨ÒéÄãÓà ......
1. C++ËäÈ»Ö÷ÒªÊÇÒÔCµÄ»ù´¡·¢Õ¹ÆðÀ´µÄÒ»ÃÅÐÂÓïÑÔ£¬µ«Ëý²»ÊÇCµÄÌæ´úÆ·£¬²»ÊÇCµÄÉý¼¶£¬C++ºÍCÊÇÐֵܹØϵ¡£Ã»ÓÐ˱ÈËÏȽøµÄ˵·¨£¬¸üÖØÒªµÄÒ»µãÊÇCºÍC++¸÷×Եıê׼ίԱ»áÊǶÀÁ¢µÄ£¬×îеÄC++±ê×¼ÊÇC++98£¬×îеÄC±ê×¼ÊÇC99¡£Òò´ËҲûÓÐÏÈѧCÔÙ˵C++µÄ˵·¨£¬Ò²²»ÔÙ£¨×¢ÒâÕâ¸ö"²»ÔÙ"£©ÓÐC++Óï·¨ÊÇCÓï·¨µÄ³¬¼¯µÄ˵·¨¡£
2. C++/CL ......
//#include "stdafx.h"
/*
ÃèÊö:´¿cÄ£ÄâÀà,´¿c±àдc++Àà,´¿cʵÏÖc++ÀàµÄ¼òµ¥·¶Àý,½á¹¹Ä£ÄâÀà,struct ±àдclass.
c±àдÀàÊÇʵÏÖ´¿c±àдcom×é¼þµÄ»ù´¡¡£
*/
#include <stdio.h>
typedef struct _Vtbl
{
void (*AddRef)(struct CObject* obj,int);//ËùÓеĺ¯ÊýµÄµÚÒ»¸ö²ÎÊýÀàËÆclassµÄÒþÄäµÄ ......
Ò»¡¢
1¡¢¹ØÓÚ×Ö½Ú˳Ðò£º»°ËµÔÚÌض¨µÄÓ²¼þƽ̨ÉÏ£¬¶à×Ö½ÚÊý¾ÝµÄ˳Ðò´æ·ÅÓÐÁ½ÖÖ·½Ê½£¨little-endian¡¢big-endian£©¡£Ç°ÕßµÄÊý¾ÝµÄµÍ×Ö½Ú
²¿·Ö´æ·ÅÔڵ͵ØÖ·Äڴ棬ºóÕßÇ¡ºÃÏà·´¡£PCÒ»°ãÊÇ»ùÓÚIA-32΢´¦ÀíÆ÷£¬ÊôÓÚlittle-endian¡£Ä³Ð©RISC¼Ü¹¹µÄCPU£¬ÀýÈçSPARC¡¢
POWERPCµÈ£¬ÔòÊ ......