±àÒë³öÀ´µÄc/c++³ÌʽµÄ²ÎÊýѹջ˳ÐòÖ»ºÍ±àÒëÆ÷Ïà¹Ø!
ÏÂÃæÁоÙÁËһЩ³£¼ûµÄ±àÒëÆ÷µÄµ÷ÓÃÔ¼¶¨
VC6:
µ÷ÓÃÔ¼¶¨ ¶ÑÕ»Çå³ý ²ÎÊý´«µÝ
__cdecl µ÷ÓÃÕß ´ÓÓÒµ½×ó,ͨ¹ý¶ÑÕ»´«µÝ
__stdcall º¯ÊýÌå ´ÓÓÒµ½×ó,ͨ¹ý¶ÑÕ»´«µÝ
__fastcall º¯ÊýÌå ´ÓÓÒµ½×ó,ÓÅÏÈʹÓüĴæÆ÷(ECX,EDX),È»ºóʹÓöÑÕ»
thiscall º¯ÊýÌå thisÖ¸ÕëĬÈÏͨ¹ýECX´«µÝ,ÆäËû²ÎÊý´ÓÓÒµ½×óÈëÕ»
__cdeclÊÇC£ÜC++µÄĬÈϵ÷ÓÃÔ¼¶¨; VCµÄµ÷ÓÃÔ¼¶¨Öв¢Ã»ÓÐthiscallÕâ¸ö¹Ø¼ü×Ö,ËûÊÇÀà³ÉÔ±º¯ÊýĬÈϵ÷ÓÃÔ¼¶¨;
C£ÜC++ÖеÄmain(»òwmain)º¯ÊýµÄµ÷ÓÃÔ¼¶¨±ØÐëÊÇ__cdecl,²»ÔÊÐí¸ü¸Ä;
ĬÈϵ÷ÓÃÔ¼¶¨Ò»°ãÄܹ»Í¨¹ý±àÒëÆ÷ÅäÖýøÐиü¸Ä,¼ÙÈçÄúµÄ´úÂëÒÀÀµÓÚµ÷ÓÃÔ¼¶¨,ÇëÃ÷È·Ö¸³öÐèҪʹÓõĵ÷ÓÃÔ¼¶¨;
C++Builder6:
µ÷ÓÃÔ¼¶¨ ¶ÑÕ»Çå³ý ²ÎÊý´«µÝ
__fastcall º¯ÊýÌå ´Ó×óµ½ÓÒ,ÓÅÏÈʹÓüĴæÆ÷(EAX,EDX,ECX),È»ºóʹÓöÑÕ» (¼æÈÝDelphiµÄregister)
(registerºÍ__fastcallµÈͬ)
__pascal º¯ÊýÌå ´Ó×óµ½ÓÒ,ͨ¹ý¶ÑÕ»´«µÝ
__cdecl µ÷ÓÃÕß ´ÓÓÒµ½×ó,ͨ¹ý¶ÑÕ»´«µÝ(ºÍC£ÜC++ĬÈϵ÷ÓÃÔ¼¶¨¼æÈÝ)
__stdcall º¯ÊýÌå ´ÓÓÒµ½×ó,ͨ¹ý¶ÑÕ»´«µÝ(ºÍVCÖеÄ__stdcall¼æÈÝ)
__msfastcall º¯ÊýÌå ´ÓÓÒµ½×ó,ÓÅÏÈʹÓüĴæÆ÷(ECX,EDX
Ïà¹ØÎĵµ£º
1.1.1 ¸ñʽ»¯ÊäÈëÊä³öº¯Êý
Turbo C2.0 ±ê×¼¿âÌṩÁËÁ½¸ö¿ØÖÆ̨¸ñʽ»¯ÊäÈë¡¢ Êä³öº¯Êýprintf( ) ºÍ
scanf(), ÕâÁ½¸öº¯Êý¿ÉÒÔÔÚ±ê×¼ÊäÈëÊä³öÉ豸ÉÏÒÔ¸÷ÖÖ²»Í¬µÄ¸ñʽ¶ÁдÊý¾Ý¡£
printf()º¯ÊýÓÃÀ´Ïò±ê×¼Êä³öÉ豸(ÆÁÄ»)дÊý¾Ý; scanf() º¯ÊýÓÃÀ´´Ó±ê×¼ÊäÈë
É豸(¼üÅÌ)É϶ÁÊý¾Ý¡£ÏÂÃæÏêϸ½éÉÜÕâÁ½¸öº¯ÊýµÄÓ÷¨¡£
Ò»¡¢pr ......
#pragma Ö¸Áî¿ÉÄÜÊÇ×ÔÓµÄÁË£¬ËüµÄ×÷ÓÃÊÇÉ趨±àÒëÆ÷µÄ״̬»òÕßÊÇָʾ±àÒëÆ÷Íê³ÉһЩÌض¨µÄ¶¯×÷¡£
#pragma Ö¸Áî¶Ôÿ¸ö±àÒëÆ÷¸ø³öÁËÒ»¸ö·½·¨,ÔÚ±£³ÖÓëC ºÍC ++ÓïÑÔÍêÈ«¼æÈݵÄÇé¿öÏÂ,¸ø³öÖ÷»ú»ò²Ù×÷ϵͳרÓеÄÌØÕ÷¡£
ÒÀ¾Ý¶¨Òå,±àÒëָʾÊÇ»úÆ÷»ò²Ù×÷ϵͳרÓеÄ,ÇÒ¶ÔÓÚÿ¸ö±àÒëÆ÷¶¼ÊDz»Í¬µÄ¡£
Ò»¡¢#pragma message
#pragma ......
ÀîÈôÀÏʦÔø¾Ëµ£ºÊÀ½çÉϵijÌÐòÔ±·ÖÈýÖÖ£¬Ò»ÖÖÊÇÓÃEmacs£¬Ò»ÖÖÊÇÓÃVimµÄ£¬ÆäËüµÄ¹éΪµÚÈýÖÖ¡£ÆäÒâÊÇ˵Èç¹ûÒ»¸ö³ÌÐòÔ±Á½Õ߶¼²»ÓõĻ°£¬ÄÇ´óµÖÊDz»ÄÜ
¹éΪÈëÁ÷ÕßÐÐÁеġ£¶ÔʹÓÃC/C++µÄÈËÀ´Ëµ£¬ºÜ¶àÈËϲ»¶Emacs£¬¾Ý˵Óë¶ÔStallmanµÄ³ç°ÝÓë°®Îݼ°ÎÚÓйØ;-)¡¡µ±È»£¬EmacsÓëVimËä
È»ÔÚÎı¾±à¼·½ÃæµÄÐÔÄÜÊǵȼ۵ģ¬µ«Ê¹ÓÃÆðÀ´Á½Õ ......
C/C++µÄ¶ÑÕ»£¬ÄÚ´æ·ÖÅä
2008Äê12ÔÂ02ÈÕ ÐÇÆÚ¶þ 11:51
Ò»¡¢Ò»¸ö¾¹ý±àÒëµÄC/C++µÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·Ö³ÉÒÔϼ¸¸ö²¿·Ö£º
1¡¢Õ»Çø£¨stack£©£ºÓɱàÒëÆ÷×Ô¶¯·ÖÅäºÍÊÍ·Å £¬´æ·Åº¯ÊýµÄ²ÎÊýÖµ¡¢¾Ö²¿±äÁ¿µÄÖµµÈ£¬ÉõÖÁº¯ÊýµÄµ÷Óùý³Ì¶¼ÊÇÓÃÕ»À´Íê³É¡£Æä²Ù×÷·½Ê½ÀàËÆÓÚÊý¾Ý½á¹¹ÖеÄÕ»¡£
2¡¢¶ÑÇø£¨heap£© £ºÒ»°ãÓɳÌÐòÔ±ÊÖ¶¯ÉêÇëÒÔ¼°ÊÍ ......