extern c ̸
C++ÓïÑԵĴ´½¨³õÖÔÊÇ“a better C”,µ«ÊÇÕâ²¢²»Òâζ×ÅC++ÖÐÀàËÆCÓïÑÔµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýËù²ÉÓõıàÒëºÍÁ¬½Ó·½Ê½ÓëCÓïÑÔÍêÈ«Ïàͬ.×÷ΪһÖÖÓûÓëC¼æÈݵÄÓïÑÔ,C++±£ÁôÁËÒ»²¿·Ö¹ý³ÌʽÓïÑÔµÄÌصã(±»ÊÀÈ˳ÆΪ“²»³¹µ×µØÃæÏò¶ÔÏó”),Òò¶øËü¿ÉÒÔ¶¨Òå²»ÊôÓÚÈκÎÀàµÄÈ«¾Ö±äÁ¿ºÍº¯Êý.µ«ÊÇ,C++±Ï¾¹ÊÇÒ»ÖÖÃæÏò¶ÔÏóµÄ³ÌÐòÉè¼ÆÓïÑÔ,ΪÁËÖ§³Öº¯ÊýµÄÖØÔØ,C++¶ÔÈ«¾Öº¯ÊýµÄ´¦Àí·½Ê½ÓëCÓÐÃ÷ÏԵIJ»Í¬.
2.´Ó±ê׼ͷÎļþ˵Æð
ijÆóÒµÔø¾¸ø³öÈçϵÄÒ»µÀÃæÊÔÌâ:
ÃæÊÔÌâ
Ϊʲô±ê׼ͷÎļþ¶¼ÓÐÀàËÆÒÔϵĽṹ?
#ifndef __INCvxWorksh
#define __INCvxWorksh
#ifdef __cplusplus
extern "C" {
#endif
/*...*/
#ifdef __cplusplus
}
#endif
#endif /* __INCvxWorksh */
·ÖÎö
ÏÔÈ»,Í·ÎļþÖеıàÒëºê“#ifndef __INCvxWorksh¡¢#define __INCvxWorksh¡¢#endif” µÄ×÷ÓÃÊÇ·ÀÖ¹¸ÃÍ·Îļþ±»Öظ´ÒýÓÃ.
ÄÇô
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
µÄ×÷ÓÃÓÖÊÇʲôÄØ?ÎÒÃǽ«ÔÚÏÂÎÄÒ»Ò»µÀÀ´.
3.Éî²ã½ÒÃÜextern "C"
extern "C" °üº¬Ë«Öغ¬Òå,´Ó×ÖÃæÉϼ´¿ÉµÃµ½:Ê×ÏÈ,±»ËüÐÞÊεÄÄ¿±êÊÇ“extern”µÄ;Æä´Î,±»ËüÐÞÊεÄÄ¿±êÊÇ“C”µÄ.ÈÃÎÒÃÇÀ´Ïêϸ½â¶ÁÕâÁ½Öغ¬Òå.
(1) ±»extern "C"ÏÞ¶¨µÄº¯Êý»ò±äÁ¿ÊÇexternÀàÐ͵Ä;
externÊÇC/C++ÓïÑÔÖбíÃ÷º¯ÊýºÍÈ«¾Ö±äÁ¿×÷Ó÷¶Î§(¿É¼ûÐÔ)µÄ¹Ø¼ü×Ö,¸Ã¹Ø¼ü×Ö¸æËß±àÒëÆ÷,ÆäÉùÃ÷µÄº¯ÊýºÍ±äÁ¿¿ÉÒÔÔÚ±¾Ä£¿é»òÆäËüÄ£¿éÖÐʹÓÃ.¼Çס,ÏÂÁÐÓï¾ä:
extern int a;
½ö½öÊÇÒ»¸ö±äÁ¿µÄÉùÃ÷,Æä²¢²»ÊÇÔÚ¶¨Òå±äÁ¿a,²¢Î´Îªa·ÖÅäÄÚ´æ¿Õ¼ä.±äÁ¿aÔÚËùÓÐÄ£¿éÖÐ×÷ΪһÖÖÈ«¾Ö±äÁ¿Ö»Äܱ»¶¨ÒåÒ»´Î,·ñÔò»á³öÏÖÁ¬½Ó´íÎó.
ͨ³£,ÔÚÄ£¿éµÄÍ·ÎļþÖжԱ¾Ä£¿éÌṩ¸øÆäËüÄ£¿éÒýÓõĺ¯ÊýºÍÈ«¾Ö±äÁ¿ÒԹؼü×ÖexternÉùÃ÷.ÀýÈç,Èç¹ûÄ£¿éBÓûÒýÓøÃÄ£¿éAÖж¨ÒåµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýʱֻÐè°üº¬Ä£¿
Ïà¹ØÎĵµ£º
1.·Ö²ãÉè¼Æ£¬¸ôÀëƽ̨Ïà¹ØµÄ´úÂë¡£¾ÍÏñ¿É²âÊÔÐÔÒ»Ñù£¬¿ÉÒÆÖ²ÐÔÒ²Òª´ÓÉè¼Æ×¥Æð¡£Ò»°ãÀ´Ëµ£¬×îÉϲãºÍ×îϲ㶼²»¾ßÓÐÁ¼ºÃµÄ¿ÉÒÆÖ²ÐÔ¡£×îÉϲãÊÇ
GUI£¬´ó¶àÊýGUI¶¼²»ÊÇ¿çƽ̨µÄ£¬ÈçWin32 SDKºÍMFC¡£×îϲãÊDzÙ×÷ϵͳAPI£¬´ó¶à²¿·Ö²Ù×÷ϵͳAPI¶¼ÊÇרÓõġ£
¡¡¡¡
Èç¹ûÕâÁ½²ãµÄ´úÂëÉ¢²¼ÔÚÕû¸öÈí¼ ......
ºÍÔÚIDEÖбàÒëÏà±È£¬ÃüÁîÐÐģʽ±àÒëËٶȸü¿ì£¬²¢¿ÉÒÔ±ÜÃâ±»IDE²úÉúµÄһЩ¸½¼ÓÐÅÏ¢Ëù¸ÉÈÅ¡£±¾ÎĽ«½éÉÜ΢ÈíC/C++±àÒëÆ÷ÃüÁîÐÐģʽÉ趨ºÍÓ÷¨¡£ 1¡¢ÉèÖû·¾³±äÁ¿£º PATH=C:\Program Files\Microsoft Visual Studio 8\VC\bin INCLUDE=C:\Program Files\Microsoft Visual Studio 8\VC\include LIB=C:\Program Files\Microsof ......
[C/C++ Digestion] –
×Ôµ×ÏòÉϵØ̽¾¿Ð麯Êý
×÷Õߣº
Jason Lee @
http://blog.csdn.net/jasonblog
ÈÕÆÚ£º
2010-05-19
»·¾³£º
Visual C++ Express
2008
ÉùÃ÷£º±¾ÎÄ·¢±íÔÚ
csdn
²©¿Í£¬ÈçÓÐתÔØ£¬Çë×¢Ã÷³ö´¦
[1]C++
¶ÔÏóÄ£ÐÍ»ù´¡
Ò»¸öÀàÖпÉÒÔ°üº¬¾²Ì¬Êý¾Ý³ÉÔ±¡¢¾²Ì¬³ÉÔ±º¯Êý¡¢·Ç¾²Ì¬³ÉÔ±º¯Êýº ......
ÓÉÓÚÒª²âϵͳµÄCPUÊôÐÔ£¬ÐèÒª¶ÀÁ¢±àÒëÓ¦ÓóÌÐò£¬±ãÊÔÁËϱàÒë´¿C ³ÌÐò£¬²âÊÔͨ¹ý¡£
CC := $(NDK_BASE)/toolchain/arm-eabi/bin/arm-eabi-gcc
AR := $(NDK_BASE)/toolchain/arm-eabi/bin/arm-eabi-ar
INC & ......