当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: 我想买块卡,他的名字叫 srt卡。我有2个问题不明白: ----------------------------原文----------------------- 这种卡在一台电脑上能同时使用几块? 这种卡提供开发包吗? --------------------------原文完毕---------------------- (翻译者:明白我的意识吗? 有些卡在电脑上只能插一块,多了就有冲......
    摘要: 公司在杭州的研发中心现在怎么样了? 还在继续吗? 谢谢. ......


对extern “C"的理解还是不够

天资愚钝,没有祥加指点参不透。

NO.1   作者: realdreamer

c++与c的编译器不同.   c++对符号(你可以简单理解为函数名,   变量名等)会做一些修改.    
   
  用   extern   "C"   就是告诉c++编译器不要修改符号命名

NO.2   作者: force_eagle

同意   realdreamer(楼主英明,贫僧久仰大名,特来拜见)    
   
  extern   "C"   就是告诉c++编译器不要修改符号命名,以C原来的函数或变量符号输出!!!!  
 

NO.3   作者: rivershan

Mixed-Language   Programming   with   C++  
  Home   |     Overview   |     How   Do   I  
   
  C++   uses   the   same   calling   convention   and   parameter-passing   techniques   as   C,   but   naming   conventions   are   different   because   of   C++   decoration   of   external   symbols.   By   causing   C++   to   drop   name   decoration,   the   extern   "C"   syntax   makes   it   possible   for   a   C++   module   to   share   data   and   routines   with   other   languages.  
   
  The   following   example   declares   prn   as   an   external   function   using   the   C   naming   convention.   This   declaration   appears   in   C++   source   code.  
   
  extern   "C"  
  {  
          void   prn();  
  }  
   
  To   call   functions   written   in   Fortran   (or   MASM),   declare   the   function   as   you   would   in   C   and   use   a   "C"   linkage   specification.   For   example,   to   call   the   Fortran   function   FACT   from   C++,   declare   it   as   follows:  
   
  extern   "C"   {   int   __stdcall   FACT(   int   n   );   }  
   
  The   extern   "C"   syntax   can   be   used   to   adjust   a   call   from   C++   to   other   languages,   or   to   change   the   naming   convention   of   C++   routines   called   from   other   languages.   However,   extern   "C"   can   be   used   only   from   within   C++.   If   the   C++   code   does   not   use   extern   "C"   and   cannot   be   changed,   you   can   call   C++   routines   only   by   determining   the   name   decoration   and   generating   it   from   the   other   language.   You   can   always   determine   the   decoration   by   using   the   DUMPBIN   utility.   Use   this   approach   only   as   a   last   resort,   because   the   decoration   scheme   is   not   guaranteed   to   remain   the   same   between   versions.  
   
  Use   of   extern   "C"   has   some   restrictions:    
   
  You   cannot   declare   a   member   function   with   extern   "C".  
   
   
  You   can   specify   extern   "C"   for   only   one   instance   of   an   overloaded   function;   all   other   instances   of   an   overloaded   function   have   C++   linkage.    
  For   more   information   on   the   extern   "C"   linkage   specification,   seeLinkage   Specifications   in   C++   Language   Reference.  
   
   
  --------------------------------------------------------------------------------  
  Send   feedback   to   MSDN.Look   here   for   MSDN   Online   resources.


    摘要: 老板叫我给出一个与串口设备进行通讯的通用程序,(主要为医疗设备,能通过修改配置读取不同设备发送上来的数据)。我没有头绪了,请各位大虾或有经验的大哥帮忙提点建议。分数无所谓,解决问题要多少分都行,最好能给出有用的代码。 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE