Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

extern ¡°C"×÷ÓÃ

1¡¢ÔÚcppÎļþÖе÷ÓÃcÎļþÖÐʵÏֵĺ¯ÊýµÄʱºò£¬ÐèÒªÓÃextern "C"ÉùÃ÷¸Ãº¯Êý£¬·ñÔòcpp»á°´Ãû×ָıàºóµÄ
º¯ÊýÃûÈ¥ÕҸú¯Êý¶øÕÒ²»µ½¡£
cppÎļþµ÷ÓÃcÎļþÖк¯ÊýÈçÏ£º
   cÎļþÖÐÓÐÒ»º¯Êý£º
              void Transfer(int a; char b);
   cppÎļþÖбØÐëÓÃextern "C"ÉùÃ÷¸Ãº¯ÊýÈçϲſÉÒÔʵÐе÷Óãº
            extern "C" void Transfer(int a; char b);
2¡¢ÔÚcppÎļþÖÐʵÏֵĺ¯Êý£¬cÎļþÈôÒªµ÷Ó㬾ͱØÐëÔÚcppÎļþÖÐÓÃextern "C"À´ÉùÃ÷¸Ãº¯Êý£¬·ñÔòcppÔÚ±àÒë¹ý³ÌÖоÍ
»á¶ÔÆä½øÐÐÃû×ָı࣬cÎļþ¾ÍÕÒ²»µ½¸Ãº¯ÊýµÄÔ­ÐÍ¡£
  cppÎļþÖÐÓÐÒ»º¯Êý£º
               void Transfer(int a; char b);
   µ«±ØÐëÓÃextern "C"À´ÉùÃ÷ºó£¬ÈçÏ£º
                extern "C" void Transfer(int a; char b);
   cÎļþ²Å¿ÉÒÔµ÷ÓÃvoid Transfer(int a; char b)º¯Êý¡£
×ܽ᣺ÒÔÉϽ²µÄÊÇÁ½¸ö·½Ã棬1Öн²cppµ÷ÓÃc£¬2Öн²cµ÷ÓÃcpp¡£
   extern "C" Ä¿µÄ£ºÊµÏÖC++ÓëC¼°ÆäËüÓïÑԵĻìºÏ±à³Ì¡£
´óÌåÉÏ£¬Äã¿ÉÒÔ°Ñextern   ºÍ   include   µÄÇø±ðµ±×öÊÇ“ÁãÊÛ”Óë“Åú·¢”µÄÇø±ð¡£includeÊÇÅú·¢£¬¶øextern   ÔòÊÇÁãÊÛ¡£


Ïà¹ØÎĵµ£º

C/C++ÊÇ×îÖ÷ÒªµÄ±à³ÌÓïÑÔ,ÕâÀïÁгöÁË50ÃûÓÅÐãÍøÕ¾

C/C++ÊÇ×îÖ÷ÒªµÄ±à³ÌÓïÑÔ¡£ÕâÀïÁгöÁË50ÃûÓÅÐãÍøÕ¾ºÍÍøÒ³Çåµ¥£¬ÕâÐ©ÍøÕ¾Ìṩc/c++Ô´´úÂë ¡£Õâ·ÝÇåµ¥ÌṩÁËÔ´´úÂëµÄÁ´½ÓÒÔ¼°ËüÃǵÄС˵Ã÷¡£ÎÒÒѾ¡Á¦°üÀ¨×î¼ÑµÄC/C++Ô´´úÂëµÄÍøÕ¾¡£Õâ²»ÊÇÒ»¸öÍêÕûµÄÇåµ¥£¬ÄúÓн¨Òé¿ÉÒÔÁªÏµÎÒ£¬ÎÒ½«»¶Ó­ÄúµÄ½¨ Ò飬ÒÔ½øÒ»²½¼ÓÇ¿Õâ·½ÃæµÄÇåµ¥¡£
1¡¢http://snippets.dzone.com/tag/c/ --ÊýÒÔǧ ......

¼¸ÖÖC/C++µÄº¯Êýѹջ·½Ê½

Ò»£¬²»Í¬¹Ø¼ü×Ö£¬ÏµÍ³Ñ¹Õ»·½Ê½
1£¬Èç¹ûº¯ÊýfuncÊÇ__cdecl(VCϵÄĬÈϵ÷Ó÷½Ê½)£¬µ÷ÓÃʱÇé¿öÈçÏÂ
int main()
{
//²ÎÊý´ÓÓÒµ½×óѹջ
push 4
push 3
push 2
push 1
call func
add esp 0x10 //µ÷ÓÃÕ߻ָ´¶ÑÕ»Ö¸Õëesp£¬4¸ö²ÎÊýµÄ´óСÊÇ0x10(4x4)
}
Cµ÷ÓÃÔ¼¶¨£¨¼´ÓÃ__cdecl¹Ø¼ü×Ö˵Ã÷£©°´´ÓÓÒÖÁ×óµÄ˳Ðòѹ² ......

C/C++/Java forÓï¾ä¹æ·¶Ð´·¨Ç³Îö(¶þÖØ¼°ÒÔÉÏÑ­»·)

 ¾Ù¸ö¼òµ¥Àý×Ó£ºÓöþÖØÑ­»·Êä³ö1-100 Êý×Ö£»
 µ±È»ÎÒÕâÀïÊǾÙÀý×ÓÕë¶Ô¶þÖØ¼°ÒÔÉϵÄÑ­»·£¬
ÍêÈ«¿ÉÒÔʹÓõ¥Ñ­»·£¬ÓÚÊDZã·É¿ìµÄÍê³ÉÁËÒÔÏÂ
 ´úÂ룺
  ÈçϾÍÓÃC/C++¾ÙÀý¡£
 C++´úÂë(VS2008):
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(in ......

C/C++´«µÝ¶þάÊý×é

C/C++´«µÝ¶þάÊý×é - [IT×ÊÁÏ]
//cÓïÑÔÖо­³£ÐèҪͨ¹ýº¯Êý´«µÝ¶þάÊý×飬ÓÐÈýÖÖ·½·¨¿ÉÒÔʵÏÖ£¬ÈçÏ£º
//·½·¨Ò»£¬ Ðβθø³öµÚ¶þάµÄ³¤¶È¡£
#include <stdio.h>
void func(int n, char str[][5])
{
           int i;
      & ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ