| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> c/c++ >> C++ zhong extern “C” han yi shen ceng tan suo

C++ zhong extern “C” han yi shen ceng tan suo

2008-06-01 02:04:57 编辑來源:互联网 评论
 
 
 
本文为【C++中extern “C”含义深层探索】的拼音翻译版
  1. yin yan
  C++ yu yan de chuang jian chu zhong shi “a better C”, dan shi zhe bing bu yi wei zhe C++ zhong lei si C yu yan de quan ju bian liang he han shu suo cai yong de bian yi he lian jie fang shi yu C yu yan wan quan xiang tong 。
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  zuo wei yi zhong yu yu C jian rong de yu yan ,C++ bao liu le yi bu fen guo cheng shi yu yan de te dian ( bei shi ren cheng wei “ bu che di di mian xiang dui xiang ”), yin er ta ke yi ding yi bu shu yu ren he lei de quan ju bian liang he han shu 。 dan shi ,C++ jiu jing shi yi zhong mian xiang dui xiang de cheng xu she ji yu yan , wei le zhi chi han shu de chong zai ,C++ dui quan ju han shu de chu li fang shi yu C you ming xian de bu tong 。2. cong biao zhun tou wen jian shuo qi
  mou qi ye zeng jing gei chu ru xia de yi dao mian shi ti :
  mian shi ti
  wei shen me biao zhun tou wen jian dou you lei si yi xia de jie gou ?
  #ifndef __INCvxWorksh
  #define __INCvxWorksh
  #ifdef __cplusplus
  extern "C" {
  #endif
  /*...*/
  #ifdef __cplusplus
  }
  #endif
  #endif /* __INCvxWorksh */
  fen xi
  xian ran , tou wen jian zhong de bian yi hong “#ifndef __INCvxWorksh、#define __INCvxWorksh、#endif” de zuo yong shi fang zhi gai tou wen jian bei chong fu yin yong 。
  na me
  #ifdef __cplusplus
  extern "C" {
  #endif
  #ifdef __cplusplus
  }
  #endif
  de zuo yong you shi shen me ne ? wo men jiang zai xia wen yi yi dao lai 。
  
C++中extern “C”含义深层探索
geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo
  3. shen ceng jie mi extern "C"
  extern "C" bao han shuang chong han yi , cong zi mian shang ji ke de dao : shou xian , bei ta xiu shi de mu biao shi “extern” de ; qi ci , bei ta xiu shi de mu biao shi “C” de 。 rang wo men lai ju ti jie du zhe liang chong han yi 。
  bei extern "C" xian ding de han shu huo bian liang shi extern lei xing de ;
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  extern shi C/C++ yu yan zhong biao ming han shu he quan ju bian liang zuo yong fan wei ( ke jian xing ) de yao hai zi , gai yao hai zi gao su bian yi qi , qi sheng ming de han shu he bian liang ke yi zai ben mo kuai huo qi ta mo kuai zhong shi yong 。 ji zhu , xia lie yu ju :
  extern int a;
  jin jin shi yi ge bian liang de sheng ming , qi bing bu shi zai ding yi bian liang a, bing wei wei a fen pei nei cun kong jian 。 bian liang a zai suo you mo kuai zhong zuo wei yi zhong quan ju bian liang zhi neng bei ding yi yi ci , fou ze hui chu xian lian jie cuo wu 。
  tong chang , zai mo kuai de tou wen jian zhong dui ben mo kuai ti gong gei qi ta mo kuai yin yong de han shu he quan ju bian liang yi yao hai zi extern sheng ming 。 li ru , jia ru mo kuai B yu yin yong gai mo kuai A zhong ding yi de quan ju bian liang he han shu shi zhi xu bao han mo kuai A de tou wen jian ji ke 。 zhe yang , mo kuai B zhong tiao yong mo kuai A zhong de han shu shi , zai bian yi jie duan , mo kuai B sui ran zhao bu dao gai han shu , dan shi bing bu hui bao cuo ; ta hui zai lian jie jie duan zhong cong mo kuai A bian yi sheng cheng de mu biao dai ma zhong zhao dao ci han shu 。
  yu extern dui ying de yao hai zi shi static, bei ta xiu shi de quan ju bian liang he han shu zhi neng zai ben mo kuai zhong shi yong 。 yin ci , yi ge han shu huo bian liang zhi ke neng bei ben mo kuai shi yong shi , qi bu ke neng bei extern “C” xiu shi 。
  bei extern "C" xiu shi de bian liang he han shu shi an zhao C yu yan fang shi bian yi he lian jie de ;
  wei jia extern “C” sheng ming shi de bian yi fang shi
  shou xian kan kan C++ zhong dui lei si C de han shu shi zen yang bian yi de 。
  zuo wei yi zhong mian xiang dui xiang de yu yan ,C++ zhi chi han shu chong zai , er guo cheng shi yu yan C ze bu zhi chi 。 han shu bei C++ bian yi hou zai fu hao ku zhong de ming zi yu C yu yan de bu tong 。 li ru , jia she mou ge han shu de yuan xing wei :
  void foo( int x, int y );
  gai han shu bei C bian yi qi bian yi hou zai fu hao ku zhong de ming zi wei _foo, er C++ bian yi qi ze hui chan sheng xiang _foo_int_int zhi lei de ming zi ( bu tong de bian yi qi ke neng sheng cheng de ming zi bu tong , dan shi dou cai yong le xiang tong de ji zhi , sheng cheng de xin ming zi cheng wei “mangled name”)。
  _foo_int_int zhe yang de ming zi bao han le han shu ming 、 han shu shen shu shu liang ji lei xing xin xi ,C++ jiu shi kao zhe zhong ji zhi lai shi xian han shu chong zai de 。 li ru , zai C++ zhong , han shu void foo( int x, int y ) yu void foo( int x, float y ) bian yi sheng cheng de fu hao shi bu xiang tong de , hou zhe wei _foo_int_float。
  
C++中extern “C”含义深层探索
geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo
  tong yang di ,C++ zhong de bian liang chu zhi chi ju bu bian liang wai , huan zhi chi lei cheng yuan bian liang he quan ju bian liang 。 yong hu suo bian xie cheng xu de lei cheng yuan bian liang ke neng yu quan ju bian liang tong ming , wo men yi "." lai qu fen 。 er ben zhi shang , bian yi qi zai jin xing bian yi shi , yu han shu de chu li xiang si , ye wei lei zhong de bian liang qu le yi ge du yi wu er de ming zi , zhe ge ming zi yu yong hu cheng xu zhong tong ming de quan ju bian liang ming zi bu tong 。
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  wei jia extern "C" sheng ming shi de lian jie fang shi
  jia she zai C++ zhong , mo kuai A de tou wen jian ru xia :
  // mo kuai A tou wen jian moduleA.h
  #ifndef MODULE_A_H
  #define MODULE_A_H
  int foo( int x, int y );
  #endif
  zai mo kuai B zhong yin yong gai han shu :
  // mo kuai B shi xian wen jian moduleB.cpp
  #include "moduleA.h"
  foo(2,3);
  shi ji shang , zai lian jie jie duan , lian jie qi hui cong mo kuai A sheng cheng de mu biao wen jian moduleA.obj zhong xun zhao _foo_int_int zhe yang de fu hao !
  jia extern "C" sheng ming hou de bian yi he lian jie fang shi
  jia extern "C" sheng ming hou , mo kuai A de tou wen jian bian wei :
  // mo kuai A tou wen jian moduleA.h
  #ifndef MODULE_A_H
  #define MODULE_A_H
  extern "C" int foo( int x, int y );
  #endif
  zai mo kuai B de shi xian wen jian zhong reng ran tiao yong foo( 2,3 ), qi jie guo shi :
  (1) mo kuai A bian yi sheng cheng foo de mu biao dai ma shi , mei you dui qi ming zi jin xing fei fan chu li , cai yong le C yu yan de fang shi ;
  (2) lian jie qi zai wei mo kuai B de mu biao dai ma xun zhao foo(2,3) tiao yong shi , xun zhao de shi wei jing xiu gai de fu hao ming _foo。
  jia ru zai mo kuai A zhong han shu sheng ming le foo wei extern "C" lei xing , er mo kuai B zhong bao han de shi extern int foo( int x, int y ) , ze mo kuai B zhao bu dao mo kuai A zhong de han shu ; fan zhi yi ran 。
  suo yi , ke yi yong yi ju hua gai kuo extern “C” zhe ge sheng ming de zhen shi mu de ( ren he yu yan zhong de ren he yu fa te xing de dan sheng dou bu shi sui yi er wei de , lai yuan yu zhen shi shi jie de xu qiu qu dong 。 wo men zai si kao wen ti shi , bu neng zhi ting liu zai zhe ge yu yan shi zen me zuo de , huan yao wen yi wen ta wei shen me yao zhe me zuo , dong ji shi shen me , zhe yang wo men ke yi geng shen ru di li jie xu duo wen ti ):
  shi xian C++ yu C ji qi ta yu yan de hun he bian cheng 。
  ming bai le C++ zhong extern "C" de she li dong ji , wo men xia mian lai ju ti fen xi extern "C" tong chang de shi yong ji qiao 。
  
C++中extern “C”含义深层探索
geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo
  4.extern "C" de guan yong fa
  (1) zai C++ zhong yin yong C yu yan zhong de han shu he bian liang , zai bao han C yu yan tou wen jian ( jia she wei cExample.h) shi , xu jin xing xia lie chu li :
  extern "C"
  {
  #include "cExample.h"
  }
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  er zai C yu yan de tou wen jian zhong , dui qi wai bu han shu zhi neng zhi ding wei extern lei xing ,C yu yan zhong bu zhi chi extern "C" sheng ming , zai .c wen jian zhong bao han le extern "C" shi hui chu xian bian yi yu fa cuo wu 。
  bi zhe bian xie de C++ yin yong C han shu li zi gong cheng zhong bao han de san ge wen jian de yuan dai ma ru xia :
  /* c yu yan tou wen jian :cExample.h */
  #ifndef C_EXAMPLE_H
  #define C_EXAMPLE_H
  extern int add(int x,int y);
  #endif
  /* c yu yan shi xian wen jian :cExample.c */
  #include "cExample.h"
  int add( int x, int y )
  {
  return x + y;
  }
  // c++ shi xian wen jian , tiao yong add:cppFile.cpp
  extern "C"
  {
  #include "cExample.h"
  }
  int main(int argc, char* argv[])
  {
  add(2,3);
  return 0;
  }
  jia ru C++ tiao yong yi ge C yu yan bian xie de .DLL shi , dang bao kuo .DLL de tou wen jian huo sheng ming jie kou han shu shi , ying jia extern "C" {}。
  (2) zai C zhong yin yong C++ yu yan zhong de han shu he bian liang shi ,C++ de tou wen jian xu tian jia extern "C", dan shi zai C yu yan zhong bu neng zhi jie yin yong sheng ming le extern "C" de gai tou wen jian , ying gai jin jiang C wen jian zhong jiang C++ zhong ding yi de extern "C" han shu sheng ming wei extern lei xing 。
  bi zhe bian xie de C yin yong C++ han shu li zi gong cheng zhong bao han de san ge wen jian de yuan dai ma ru xia :
  //C++ tou wen jian cppExample.h
  #ifndef CPP_EXAMPLE_H
  #define CPP_EXAMPLE_H
  extern "C" int add( int x, int y );
  #endif
  //C++ shi xian wen jian cppExample.cpp
  #include "cppExample.h"
  int add( int x, int y )
  {
  return x + y;
  }
  /* C shi xian wen jian cFile.c
  /* zhe yang hui bian yi chu cuo :#include "cExample.h" */
  
   extern int add( int x, int y );
  int main( int argc, char* argv[] )
  {
  add( 2, 3 );
  return 0;
  }
  jia ru shen ru li jie le di 3 jie zhong suo chan shu de extern "C" zai bian yi he lian jie jie duan fa hui de zuo yong , jiu neng zhen zheng li jie ben jie suo chan shu de cong C++ yin yong C han shu he C yin yong C++ han shu de guan yong fa 。 dui di 4 jie gei chu de shi li dai ma , xu yao fei fan liu yi ge ge xi jie 。
  huan ying yu zuo zhe lian xi gou tong 。 lian xi fang shi :
  Email: 21cnbao@21cn.com
  MSN: barrysong80@hotmail.com
C++中extern “C”含义深层探索
geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
  1. yin yan   C++ yu yan de chuang jian chu zhong shi “a better C”, dan shi zhe bing bu yi wei zhe C++ zhong lei si C yu yan de quan ju bian liang he han shu suo cai yong de bian yi he lian jie fang shi yu C yu yan wan quan xiang tong 。 zuo wei yi zhong yu yu C jian rong de yu yan ,C++ bao liu le yi bu fen guo cheng shi yu yan de te dian ( bei shi ren cheng wei “ bu che di di mian xiang dui xiang ”), yin er ta ke yi ding yi bu shu yu ren he lei de quan ju bian liang he han shu 。 dan shi ,C++ jiu jing shi yi zhong mian xiang dui xiang de cheng xu she ji yu yan , wei le zhi chi han shu de chong zai ,C++ dui quan ju han shu de chu li fang shi yu C you ming xian de bu tong 。  2. cong biao zhun tou wen jian shuo qi    mou qi ye zeng jing gei chu ru xia de yi dao mian shi ti :    mian shi ti    wei shen me biao zhun tou wen jian dou you lei si yi xia de jie gou ? #ifndef __INCvxWorksh #define __INCvxWorksh #ifdef __cplusplus extern "C" { #endif /*...*/ #ifdef __cplusplus } #endif #endif /* __INCvxWorksh */    fen xi    xian ran , tou wen jian zhong de bian yi hong “#ifndef __INCvxWorksh、#define __INCvxWorksh、#endif” de zuo yong shi fang zhi gai tou wen jian bei chong fu yin yong 。    na me #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif    de zuo yong you shi shen me ne ? wo men jiang zai xia wen yi yi dao lai 。 [url=http://www.wangchao.net.cn/bbs/pydetail_1785329.html][img]http://image.wangchao.net.cn/it/1323423860572.gif[/img][/url] geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo   3. shen ceng jie mi extern "C"   extern "C" bao han shuang chong han yi , cong zi mian shang ji ke de dao : shou xian , bei ta xiu shi de mu biao shi “extern” de ; qi ci , bei ta xiu shi de mu biao shi “C” de 。 rang wo men lai ju ti jie du zhe liang chong han yi 。    bei extern "C" xian ding de han shu huo bian liang shi extern lei xing de ;   extern shi C/C++ yu yan zhong biao ming han shu he quan ju bian liang zuo yong fan wei ( ke jian xing ) de yao hai zi , gai yao hai zi gao su bian yi qi , qi sheng ming de han shu he bian liang ke yi zai ben mo kuai huo qi ta mo kuai zhong shi yong 。 ji zhu , xia lie yu ju :   extern int a;    jin jin shi yi ge bian liang de sheng ming , qi bing bu shi zai ding yi bian liang a, bing wei wei a fen pei nei cun kong jian 。 bian liang a zai suo you mo kuai zhong zuo wei yi zhong quan ju bian liang zhi neng bei ding yi yi ci , fou ze hui chu xian lian jie cuo wu 。    tong chang , zai mo kuai de tou wen jian zhong dui ben mo kuai ti gong gei qi ta mo kuai yin yong de han shu he quan ju bian liang yi yao hai zi extern sheng ming 。 li ru , jia ru mo kuai B yu yin yong gai mo kuai A zhong ding yi de quan ju bian liang he han shu shi zhi xu bao han mo kuai A de tou wen jian ji ke 。 zhe yang , mo kuai B zhong tiao yong mo kuai A zhong de han shu shi , zai bian yi jie duan , mo kuai B sui ran zhao bu dao gai han shu , dan shi bing bu hui bao cuo ; ta hui zai lian jie jie duan zhong cong mo kuai A bian yi sheng cheng de mu biao dai ma zhong zhao dao ci han shu 。    yu extern dui ying de yao hai zi shi static, bei ta xiu shi de quan ju bian liang he han shu zhi neng zai ben mo kuai zhong shi yong 。 yin ci , yi ge han shu huo bian liang zhi ke neng bei ben mo kuai shi yong shi , qi bu ke neng bei extern “C” xiu shi 。    bei extern "C" xiu shi de bian liang he han shu shi an zhao C yu yan fang shi bian yi he lian jie de ;    wei jia extern “C” sheng ming shi de bian yi fang shi    shou xian kan kan C++ zhong dui lei si C de han shu shi zen yang bian yi de 。    zuo wei yi zhong mian xiang dui xiang de yu yan ,C++ zhi chi han shu chong zai , er guo cheng shi yu yan C ze bu zhi chi 。 han shu bei C++ bian yi hou zai fu hao ku zhong de ming zi yu C yu yan de bu tong 。 li ru , jia she mou ge han shu de yuan xing wei : void foo( int x, int y );    gai han shu bei C bian yi qi bian yi hou zai fu hao ku zhong de ming zi wei _foo, er C++ bian yi qi ze hui chan sheng xiang _foo_int_int zhi lei de ming zi ( bu tong de bian yi qi ke neng sheng cheng de ming zi bu tong , dan shi dou cai yong le xiang tong de ji zhi , sheng cheng de xin ming zi cheng wei “mangled name”)。   _foo_int_int zhe yang de ming zi bao han le han shu ming 、 han shu shen shu shu liang ji lei xing xin xi ,C++ jiu shi kao zhe zhong ji zhi lai shi xian han shu chong zai de 。 li ru , zai C++ zhong , han shu void foo( int x, int y ) yu void foo( int x, float y ) bian yi sheng cheng de fu hao shi bu xiang tong de , hou zhe wei _foo_int_float。 [url=http://www.wangchao.net.cn/bbs/pydetail_1785329.html][img]http://image.wangchao.net.cn/it/1323423860609.gif[/img][/url] geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo    tong yang di ,C++ zhong de bian liang chu zhi chi ju bu bian liang wai , huan zhi chi lei cheng yuan bian liang he quan ju bian liang 。 yong hu suo bian xie cheng xu de lei cheng yuan bian liang ke neng yu quan ju bian liang tong ming , wo men yi "." lai qu fen 。 er ben zhi shang , bian yi qi zai jin xing bian yi shi , yu han shu de chu li xiang si , ye wei lei zhong de bian liang qu le yi ge du yi wu er de ming zi , zhe ge ming zi yu yong hu cheng xu zhong tong ming de quan ju bian liang ming zi bu tong 。    wei jia extern "C" sheng ming shi de lian jie fang shi    jia she zai C++ zhong , mo kuai A de tou wen jian ru xia : // mo kuai A tou wen jian  moduleA.h #ifndef MODULE_A_H #define MODULE_A_H int foo( int x, int y ); #endif    zai mo kuai B zhong yin yong gai han shu : // mo kuai B shi xian wen jian  moduleB.cpp #include "moduleA.h" foo(2,3);    shi ji shang , zai lian jie jie duan , lian jie qi hui cong mo kuai A sheng cheng de mu biao wen jian moduleA.obj zhong xun zhao _foo_int_int zhe yang de fu hao !    jia extern "C" sheng ming hou de bian yi he lian jie fang shi    jia extern "C" sheng ming hou , mo kuai A de tou wen jian bian wei : // mo kuai A tou wen jian  moduleA.h #ifndef MODULE_A_H #define MODULE_A_H extern "C" int foo( int x, int y ); #endif    zai mo kuai B de shi xian wen jian zhong reng ran tiao yong foo( 2,3 ), qi jie guo shi :   (1) mo kuai A bian yi sheng cheng foo de mu biao dai ma shi , mei you dui qi ming zi jin xing fei fan chu li , cai yong le C yu yan de fang shi ;   (2) lian jie qi zai wei mo kuai B de mu biao dai ma xun zhao foo(2,3) tiao yong shi , xun zhao de shi wei jing xiu gai de fu hao ming _foo。    jia ru zai mo kuai A zhong han shu sheng ming le foo wei extern "C" lei xing , er mo kuai B zhong bao han de shi extern int foo( int x, int y ) , ze mo kuai B zhao bu dao mo kuai A zhong de han shu ; fan zhi yi ran 。    suo yi , ke yi yong yi ju hua gai kuo extern “C” zhe ge sheng ming de zhen shi mu de ( ren he yu yan zhong de ren he yu fa te xing de dan sheng dou bu shi sui yi er wei de , lai yuan yu zhen shi shi jie de xu qiu qu dong 。 wo men zai si kao wen ti shi , bu neng zhi ting liu zai zhe ge yu yan shi zen me zuo de , huan yao wen yi wen ta wei shen me yao zhe me zuo , dong ji shi shen me , zhe yang wo men ke yi geng shen ru di li jie xu duo wen ti ):    shi xian C++ yu C ji qi ta yu yan de hun he bian cheng 。    ming bai le C++ zhong extern "C" de she li dong ji , wo men xia mian lai ju ti fen xi extern "C" tong chang de shi yong ji qiao 。 [url=http://www.wangchao.net.cn/bbs/pydetail_1785329.html][img]http://image.wangchao.net.cn/it/1323423860653.gif[/img][/url] geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo   4.extern "C" de guan yong fa   (1) zai C++ zhong yin yong C yu yan zhong de han shu he bian liang , zai bao han C yu yan tou wen jian ( jia she wei cExample.h) shi , xu jin xing xia lie chu li : extern "C" { #include "cExample.h" }    er zai C yu yan de tou wen jian zhong , dui qi wai bu han shu zhi neng zhi ding wei extern lei xing ,C yu yan zhong bu zhi chi extern "C" sheng ming , zai .c wen jian zhong bao han le extern "C" shi hui chu xian bian yi yu fa cuo wu 。    bi zhe bian xie de C++ yin yong C han shu li zi gong cheng zhong bao han de san ge wen jian de yuan dai ma ru xia : /* c yu yan tou wen jian :cExample.h */ #ifndef C_EXAMPLE_H #define C_EXAMPLE_H extern int add(int x,int y); #endif /* c yu yan shi xian wen jian :cExample.c */ #include "cExample.h" int add( int x, int y ) { return x + y; } // c++ shi xian wen jian , tiao yong add:cppFile.cpp extern "C" { #include "cExample.h" } int main(int argc, char* argv[]) { add(2,3); return 0; }    jia ru C++ tiao yong yi ge C yu yan bian xie de .DLL shi , dang bao kuo .DLL de tou wen jian huo sheng ming jie kou han shu shi , ying jia extern "C" { }。   (2) zai C zhong yin yong C++ yu yan zhong de han shu he bian liang shi ,C++ de tou wen jian xu tian jia extern "C", dan shi zai C yu yan zhong bu neng zhi jie yin yong sheng ming le extern "C" de gai tou wen jian , ying gai jin jiang C wen jian zhong jiang C++ zhong ding yi de extern "C" han shu sheng ming wei extern lei xing 。    bi zhe bian xie de C yin yong C++ han shu li zi gong cheng zhong bao han de san ge wen jian de yuan dai ma ru xia : //C++ tou wen jian cppExample.h #ifndef CPP_EXAMPLE_H #define CPP_EXAMPLE_H extern "C" int add( int x, int y ); #endif //C++ shi xian wen jian cppExample.cpp #include "cppExample.h" int add( int x, int y ) { return x + y; } /* C shi xian wen jian cFile.c /* zhe yang hui bian yi chu cuo :#include "cExample.h" */ extern int add( int x, int y ); int main( int argc, char* argv[] ) { add( 2, 3 ); return 0; }    jia ru shen ru li jie le di 3 jie zhong suo chan shu de extern "C" zai bian yi he lian jie jie duan fa hui de zuo yong , jiu neng zhen zheng li jie ben jie suo chan shu de cong C++ yin yong C han shu he C yin yong C++ han shu de guan yong fa 。 dui di 4 jie gei chu de shi li dai ma , xu yao fei fan liu yi ge ge xi jie 。    huan ying yu zuo zhe lian xi gou tong 。 lian xi fang shi :   Email: 21cnbao@21cn.com   MSN: barrysong80@hotmail.com [url=http://www.wangchao.net.cn/bbs/pydetail_1785329.html][img]http://image.wangchao.net.cn/it/1323423860694.gif[/img][/url] geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
玉美人_珠联璧合
清纯美女米卡
清新靓丽的早晨
玲子的自信与性感
痞子的甘南日记
疑是银河落九天
雪域坝上四——纯美色
冬日恋歌——西城杨柳弄轻柔
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有