extern c×÷ÓÃ
Á´½Óָʾ·ûextern C
Èç¹û³ÌÐòԱϣÍûµ÷ÓÃÆäËû³ÌÐòÉè¼ÆÓïÑÔÓÈÆäÊÇC дµÄº¯ÊýÄÇôµ÷Óú¯Êýʱ±ØÐë
¸æËß±àÒëÆ÷ʹÓò»Í¬µÄÒªÇóÀýÈçµ±ÕâÑùµÄº¯Êý±»µ÷ÓÃʱº¯ÊýÃû»ò²ÎÊýÅÅÁеÄ˳Ðò¿ÉÄÜ
²»Í¬ÎÞÂÛÊÇC++º¯Êýµ÷ÓÃËü»¹ÊÇÓÃÆäËûÓïÑÔдµÄº¯Êýµ÷ÓÃËü
³ÌÐòÔ±ÓÃÁ´½Óָʾ·ûlinkage directive ¸æËß±àÒëÆ÷¸Ãº¯ÊýÊÇÓÃÆäËûµÄ³ÌÐòÉè¼ÆÓïÑÔ
±àдµÄÁ´½Óָʾ·ûÓÐÁ½ÖÖÐÎʽ¼È¿ÉÒÔÊǵ¥Ò»Óï¾äsingle statement ÐÎʽҲ¿ÉÒÔÊǸ´
ºÏÓï¾äcompound statement ÐÎʽ
// µ¥Ò»Óï¾äÐÎʽµÄÁ´½Óָʾ·û
extern "C" void exit(int);
// ¸´ºÏÓï¾äÐÎʽµÄÁ´½Óָʾ·û
extern "C" {
int printf( const char* ... );
int scanf( const char* ... );
}
// ¸´ºÏÓï¾äÐÎʽµÄÁ´½Óָʾ·û
extern "C" {
#include <cmath>
}
Á´½Óָʾ·ûµÄµÚÒ»ÖÖÐÎʽÓɹؼü×Öextern ºó¸úÒ»¸ö×Ö·û´®³£Á¿ÒÔ¼°Ò»¸öÆÕͨµÄº¯Êý
ÉùÃ÷¹¹³ÉËäÈ»º¯ÊýÊÇÓÃÁíÍâÒ»ÖÖÓïÑÔ±àдµÄµ«µ÷ÓÃËüÈÔÈ»ÐèÒªÀàÐͼì²éÀýÈç±àÒëÆ÷
»á¼ì²é´«µÝ¸øº¯Êýexit()µÄʵ²ÎµÄÀàÐÍÊÇ·ñÊÇint »òÕßÄܹ»ÒþʽµØת»»³Éint ÐÍ
¶à¸öº¯ÊýÉùÃ÷¿ÉÒÔÓû¨À¨ºÅ°üº¬ÔÚÁ´½Óָʾ·û¸´ºÏÓï¾äÖÐÕâÊÇÁ´½Óָʾ·ûµÄµÚ¶þÖÖÐÎ
ʽ»¨Õкű»ÓÃ×÷·Ö¸î·û±íʾÁ´½Óָʾ·ûÓ¦ÓÃÔÚÄÄЩÉùÃ÷ÉÏÔÚÆäËûÒâÒåÉϸû¨À¨ºÅ±»ºö
ÂÔËùÒÔÔÚ»¨À¨ºÅÖÐÉùÃ÷µÄº¯ÊýÃû¶ÔÍâÊǿɼûµÄ¾ÍºÃÏñº¯ÊýÊÇÔÚ¸´ºÏÓï¾äÍâÉùÃ÷µÄÒ»Ñù
ÀýÈçÔÚÇ°ÃæµÄÀý×ÓÖи´ºÏÓï¾äextern "C"±íʾº¯Êýprintf()ºÍscanf()ÊÇÔÚC ÓïÑÔÖÐдµÄ
º¯ÊýÒò´ËÕâ¸öÉùÃ÷µÄÒâÒå¾ÍÈçͬprintf()ºÍscanf()ÊÇÔÚextern "C"¸´ºÏÓï¾äÍâÃæÉùÃ÷µÄ
Ò»Ñù
µ±¸´ºÏÓï¾äÁ´½Óָʾ·ûµÄÀ¨ºÅÖк¬ÓÐ#include ʱÔÚÍ·ÎļþÖеĺ¯ÊýÉùÃ÷¶¼±»¼Ù¶¨ÊÇÓÃ
Á´½Óָʾ·ûµÄ³ÌÐòÉè¼ÆÓïÑÔËùдµÄÔÚÇ°ÃæµÄÀý×ÓÖÐÔÚÍ·Îļþ<cmath>ÖÐÉùÃ÷µÄº¯Êý¶¼ÊÇC
º¯Êý
Á´½Óָʾ·û²»ÄܳöÏÖÔÚº¯ÊýÌåÖÐÏÂÁдúÂë¶Î½«»áµ¼Ö±àÒë´íÎó
int main()
{
// ´íÎó: Á´½Óָʾ·û²»ÄܳöÏÖÔÚº¯ÊýÄÚ
extern "C" double sqrt( double );
305 µÚÆßÕº¯Êý
double getValue(); //ok
double result = sqrt ( getValue() );
//...
return 0;
}
Èç¹û°ÑÁ´½Óָʾ·ûÒƵ½º¯ÊýÌåÍâ³ÌÐò±àÒ뽫ÎÞ´íÎó
extern "C" double sqrt( double );
int main()
{
double getValue(); //ok
double result = sqrt ( getValue() );
//...
return 0;
}
µ«ÊÇ°ÑÁ´½Óָʾ·û·ÅÔÚÍ·ÎļþÖиüºÏÊÊÔÚÄÇÀﺯÊýÉùÃ÷ÃèÊöÁ˺¯ÊýµÄ½Ó¿ÚËùÊô
Èç¹ûÎÒÃÇÏ£ÍûC++º¯ÊýÄ
Ïà¹ØÎĵµ£º
Ç°ÑÔ£ºÇ°¶Îʱ¼äÔÚCSDNµÄC++ÉçÇøÓöµ½Ò»¸öÐèÒª·â×°¿¼ÇÚ»ú½Ó¿ÚµÄ¶¯Ì¬¿â¸øJAVAµ÷ÓõÄÌû×Ó£¬¹´ÆðÁËÎÒ¶ÔJAVAµÄÎÞÏÞ»³Äî¡£ÔÚ´Ë£¬ÎÒÏë°ÑÕâÏî¼¼Êõ¼òµ¥ÔÙ½éÉÜһϡ£
Ò»¡¢¹ØÓÚJava Native Interface (JNI)
JNIÊÇJAVA±¾µØ±à³Ì½Ó¿Ú£¬ÊôÓÚJDKµÄÒ»²¿·Ö¡£ËüÔÊÐíJAVAÄܹ»²Ù×÷±¾µØAPI»òÓÉÆäËûÓïÑÔ±àдµÄ¶¯Ì¬¿â¡£²»¹ýµ±ÄãʹÓÃÕâÏî¼¼ÊõµÄʱºò£ ......
%d ¶ÌÕûÐÎ,Ò»°ãÕ¼Á½¸ö×Ö½Ú
%u ÎÞ·ûºÅ¶ÌÕûÐÎ
%ld ³¤ÕûÐÎ,Ò»°ãÕ¼Ëĸö×Ö½Ú
%c ×Ö·ûÐÍ
%s ×Ö·û´®
Ö÷ÒªÓÃÔÚÊäÈëÊä³öº¯Êý£ºscanf(),printf()Àï
\a:·äÃù£¬ÏìÁå
\b:»ØÍË£ºÏòºóÍËÒ»¸ñ
\f:»»Ò³
\n:»»ÐУ¬¹â±êµ½ÏÂÐÐÐÐÊ×
\r:»Ø³µ£¬¹â±êµ½±¾ÐÐÐÐÊ×
\t:ˮƽÖƱí
\v:´¹Ö±ÖƱí ......
¸ù¾ÝACM¹Ù·½ÍøÕ¾3ÔÂ9ÈÕ·¢²¼µÄÏûÏ¢£¬2009ÄêͼÁé½±ÊÚÓèÁËÏÖ´úPCÖ®¸¸Charles Thacker£¬ÒÔ±íÕÃËû¶ÔµÚһ̨ÏÖ´ú¸öÈ˼ÆËã»úXerox PARC AltoµÄÏÈÇýÐÔÉè¼ÆÓëʵÏÖ£¬»¹ÓÐÔÚ¾ÖÓòÍø£¨°üÀ¨ÒÔÌ«Íø£©¡¢¶à´¦ÀíÆ÷¹¤×÷Õ¾¡¢¿ú̽¸ßËÙ»º´æÒ»ÖÂÐÔÐÒéºÍƽ°åPCµÈ·½ÃæµÄÖØ´ó·¢Ã÷ºÍ¹±Ï×£¨For the pioneering design andРrealization of the fi ......
<!--
/* Font Definitions */
@font-face
{font-family:ËÎÌå;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@ËÎÌå" ......
½ñÌìÔÚдµ½ÓÃcÀ´½âÎöpostÊý¾ÝµÄʱºòÐèÒªÓõ½Ò»¸öÊý×é±äÁ¿À´·ÅpostµÄËùÓÐÊý¾ÝµÈ×ÅÀ´½âÎö£¬²»ÏëÌ«ÀË·ÑÄÚ´æÁË¡£ÓÚÊÇÏë×ÅÏÈÉêÇëÒ»¸ö×î´óÍþ¶ûŶcontent_length´óСµÄÊý×éÔÙ˵¡£µ«ÊDz»ÔÊÐíÓñäÁ¿À´¡£±ÈÈç
int length = atoi(getenv("CONTENT_LENGTH"));
char params[length];
memset(params, '\0', length);
ÄÇôchar para ......