extern "C"
CºÍC++»¥Ïàµ÷Óú¯Êýʱ£¬Ê¹ÓÃextern "C"¡£
ÔÒò£º
C²»Ö§³Öº¯ÊýÖØÔØ£¬¶øC++Ö§³Öº¯ÊýÖØÔØ¡£º¯Êý±»C++±àÒëºó»áÃû×ÖÓëCÓïÑÔ²»Í¬¡£¼ÙÉèijº¯ÊýÔÐÍΪfoo(ing x, int y)£¬±»C++±àÒëºóÃû×ÖΪ_foo_int_int£¬¶øC±àÒëÆ÷±àÒëºóÃû×ÖΪ_foo¡£
Ïà¹ØÎĵµ£º
3.2 ¸ßЧÂʲâÊÔ£ºËÄÁ½°Îǧ½ï
ÉÏÒ»½Ú½éÉÜÁËһЩËÆÊǶø·ÇµÄ¸ßЧÂÊ·½·¨£¬ÄÇô£¬ÔõÑù²ÅÄÜÕæÕý¸ßЧÂʲâÊÔÄØ£¿ÕæÕýµÄ¸ßЧÂÊ£¬²»ÄܺöÂÔÈ˵ÄÖÇ»ÛÕâÒ»¹Ø¼üÒòËØ¡£
ÓÉÓÚ¹¤¾ß²»¿ÉÄÜ×Ô¶¯Á˽â´úÂëµÄÉè¼Æ¹¦ÄÜ£¬Ö»ÓÐÈ˲ÅÁ˽⣬Òò´Ë£¬Ö»ÓÐÈ˵ÄÖǻۼ°Ê±½éÈ룬¹¤¾ß²ÅÄÜ×öÕýÈ·µÄÊÂÇ飬²ÅÄÜ´ïµ½ÕæÕýµÄ¸ßЧÂÊ¡£
&nb ......
ÎÊÌâÃèÊö£ºÐ´Ò»¸öº¯Êý£¬½ÓÊÜÒ»¸öÕûÊý£¨¼Ù¶¨ÓÃint±íʾ£©£¬Êä³ö¸ÃÕûÊýµÄ×Ö·û´®ÐÎʽ¡£²ÉÓÃÈçϺ¯ÊýÔÐÍ£º
void itoa ( int val, char* buf );
ÕâÀï¼Ù¶¨buf×ã¹»´óÒÔÈÝÄÉÈκÎintÀàÐÍÊýÖµµÄ×Ö·û´®¡£
Õâ¸öÎÊÌ⣬³õ¿´ºÃÏñûÓÐʲôÄѶȡ£Èç¹ûÊÇ0£¬¾ÍÖ±½ÓÊä³ö'0'£»Èç¹ûÊÇÕýÊý£¬¾Íͨ¹ýÈ¡Ä£(%)ºÍÇóÉÌ(/)ÔËËã¿ÉÒÔÖðλȡµÃ¸ÃÕûÊýµÄÊ ......
×î½ü¶Ô»ù´¡ÖªÊ¶½øÐÐÁËѧϰ£¬·¢ÏÖÒÔÇ°ºÜ¶à¶«Î÷¶¼Ã»ÓиãÇå³þ
1. ±àÒëµÄÎÊÌ⣬ͷÎļþÖ÷ÒªÊǶ¨Òå
//////// add.c
int add(int a, int b)
{
return a + b;
}
///////// main.c
#include <stdio.h>
int add(int a, int b);
int main ()
{
printf("%d" ......
¹Ø¼üµÄʱ¿Ì - MFC Or Not
ÔÚSymantec C/C++ºÍWatcom C/C++Öð½¥µØÕ¾ÎÈÁ˽Ų½Ö®ºó£¬ËÄ´ó±àÒëÆ÷¾öÕ½µÄʱ¿ÌÒ²Ö𽥱ƽüÁË¡£ÔÚ1994ÄêδµÄ¾öս֮ǰ£¬SymantecºÍWatcomͬʱÃæ¶ÔÁËÒ»¸ö·Ç³£ÑÏÀ÷µÄ¿¼Ñ飬ÄǾÍÊÇC/C++ FrameworkµÄÑ¡Ôñ¡£ËäÈ»SymantecºÍWatcom¶¼ÒÔ¸÷×ÔµÄÌØÉ«Õ¼µÃÁËÊг¡£¬²»¹ýÔÚµ±Ê±¶ÔÓÚÒ»¸öC/C++¿ª·¢¹¤¾ßÀ´Ëµ£¬×îÖØÒªµÄÒ ......
extern cµÄ×÷Óá¾×ª¡¿
2009-12-18 13:10
1.ÒýÑÔ
C++ÓïÑԵĴ´½¨³õÖÔÊÇ“a better C”£¬µ«ÊÇÕâ²¢²»Òâζ×ÅC++ÖÐÀàËÆCÓïÑÔµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýËù²ÉÓõıàÒëºÍÁ¬½Ó·½Ê½ÓëCÓïÑÔÍêÈ«Ïàͬ¡£×÷ΪһÖÖÓûÓëC¼æÈݵÄÓïÑÔ£¬C++±£ÁôÁËÒ»²¿·Ö¹ý³Ì ʽÓïÑÔµÄÌص㣨±»ÊÀÈ˳ÆΪ“²»³¹µ×µØÃæÏò¶ÔÏ󔣩£¬Òò¶øËü¿ÉÒÔ¶¨Òå²»ÊôÓ ......