Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

extern "C"


extern "C"°üº¬Ë«Öغ¬Ò壬ÆäÒ»£º±»ËüÐÞÊεÄÄ¿±êÊÇ“extern”µÄ£»Æä¶þ£º±»ËüÐÞÊεÄÄ¿±êÊÇ“C”µÄ¡£
1£©±»extern “C”ÏÞ¶¨µÄº¯Êý»ò±äÁ¿ÊÇexternÀàÐ͵ģ»
    externÊÇC/C++ÓïÑÔÖбíÃ÷º¯ÊýºÍÈ«¾Ö±äÁ¿×÷Ó÷¶Î§£¨¿É¼ûÐÔ£©µÄ¹Ø¼ü×Ö£¬¸Ã¹Ø¼ü×Ö¸æËß±àÒëÆ÷£¬ÆäÉùÃ÷µÄº¯ÊýºÍ±äÁ¿¿ÉÒÔÔÚ±¾Ä£¿é»òÆäËûÄ£¿éÖÐʹÓá£
    ×¢Ò⣺extern int a£»
    ½ö½öÊÇÔÚÉùÃ÷Ò»¸ö±äÁ¿£¬²¢²»ÊǶ¨Òå±äÁ¿a£¬²¢Î´Îªa·ÖÅäÄÚ´æ¿Õ¼ä¡£±äÁ¿aÔÚËùÓÐÄ£¿éÖÐ×÷ΪһÖÖÈ«¾Ö±äÁ¿Ö»Äܱ»¶¨ÒåÒ»´Î£¬·ñÔò»á³öÏÖÁ¬½Ó´íÎó¡£
    ͨ³££¬ÔÚÄ£¿éµÄÍ·ÎļþÖжÔÄ£¿éÌṩ¸øÆäËûÄ£¿éÒýÓõĺ¯ÊýºÍÈ«¾Ö±äÁ¿ÒԹؼü×ÖexternÉùÃ÷¡£ÀýÈ磬Èç¹ûÄ£¿éBÓûÒýÓøÃÄ£¿éAÖж¨ÒåµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýʱֻÐè°üº¬Ä£¿éAµÄÍ·Îļþ¼´¿É¡£ÕâÑù£¬Ä£¿éBÖе÷ÓÃÄ£¿éAÖеĺ¯Êýʱ£¬ÔÚ±àÒë½×¶Î£¬Ä£¿éBËäÈ»ÕÒ²»µ½¸Ãº¯Êý£¬µ«ÊDz¢²»»á±¨´í£¬Ëü»áÔÚÁ¬½Ó½×¶ÎÖдÓÄ£¿éA±àÒëÉú³ÉµÄÄ¿±ê´úÂëÖÐÕÒµ½´Ëº¯Êý¡£
    Óëextern¶ÔÓ¦µÄ¹Ø¼ü×ÖÊÇstatic£¬±»ËüÐÞÊεÄÈ«¾Ö±äÁ¿ºÍº¯ÊýÖ»ÄÜÔÚ±¾Ä£¿éÖÐʹÓá£Òò´Ë£¬Ò»¸öº¯Êý»ò±äÁ¿Ö»¿ÉÄܱ»±¾Ä£¿éʹÓÃʱ£¬Æä²»¿ÉÄܱ»extern "C"ÐÞÊΡ£
2£©±»extern "C"ÐÞÊεıäÁ¿ºÍº¯ÊýÊÇ°´ÕÕCÓïÑÔ·½Ê½±àÒëºÍÁ¬½ÓµÄ
    ×÷ΪһÖÖÃæÏò¶ÔÏóµÄÓïÑÔ£¬C++Ö§³Öº¯ÊýÖØÔØ£¬¶ø¹ý³ÌʽÓïÑÔCÔò²»Ö§³Ö¡£º¯Êý±»C++±àÒëºóÔÚ·ûºÅ¿âÖеÄÃû×ÖÓëCÓïÑԵIJ»Í¬¡£ÀýÈ磬¼ÙÉèij¸öº¯ÊýµÄÔ­ÐÍΪ£ºvoid foo(int x, int y);
¸Ãº¯Êý±»C±àÒëÆ÷±àÒëºóÔÚ·ûºÅ¿âÖеÄÃû×ÖΪ_foo£¬¶øC++±àÒëÆ÷Ôò»á²úÉúÏñ_foo_int_intÖ®ÀàµÄÃû×Ö£¨²»Í¬µÄ±àÒëÆ÷¿ÉÄܲúÉúµÄÃû×Ö²»Í¬£¬µ«ÊǶ¼²ÉÓÃÁËÏàͬµÄ»úÖÆ£©¡£_foo_int_intÕâÑùµÄÃû×Ö°üº¬Á˺¯ÊýÃû¡¢º¯Êý²ÎÊýÊýÁ¿¼°ÀàÐÍÐÅÏ¢£¬C++¾ÍÊÇ¿¿ÕâÖÖ»úÖÆÀ´ÊµÏÖº¯ÊýÖØÔصġ£ÀýÈ磬ÔÚC++ÖУ¬º¯Êývoid foo(int x, int y)Óëvoid foo(int x, float y)±àÒë²úÉúµÄ·ûºÅÊDz»ÏàͬµÄ£¬ºóÕßΪ_foo_int_float¡£
    extern "C"×÷ÓãºÊµÏÖC++ÓëC¼°ÆäËüÓïÑԵĻìºÏ±à³Ì¡£
3£©extern "C"µÄ¹ßÓ÷¨
A£©ÔÚC++ÖÐÒýÓÃCÓïÑÔÖеĺ¯ÊýºÍ±äÁ¿£¬ÔÚ°üº¬CÓïÑÔÍ·Îļþ£¨¼ÙÉèΪcExample.h£©Ê±£¬Ðè½øÐÐÏÂÁд¦Àí£º
extern "C"
{
#include "cExample.h"
}
    ¶øÔÚCÓïÑÔµÄÍ·ÎļþÖУ¬¶ÔÆäÍⲿº¯ÊýÖ»ÄÜÖ¸¶¨ÎªexternÀàÐÍ£¬CÓïÑÔÖв»Ö§³Öextern "C"ÉùÃ÷£¬ÔÚ.cÎļþÖаüº¬ÁËextern "C"ʱ»á³öÏÖ±àÒëÓï·¨´íÎó¡£
  


Ïà¹ØÎĵµ£º

"C Run Time Error R6034"£¨×ª£©


Regarding C Run-Time Error R6034 for VS2005/VS2008
Regarding "C Run-Time Error R6034"
Microsoft's recommendation is very confusing. That is, it recommends to include a manifest file and to re-compile the project.
I recently had a problem with 'R6034' error message even with a manifest file ......

cµÄboolÀàÐÍ

C++ÄÚÖöԲ¼¶ûÀàÐ͵ÄÖ§³Ö£¬Æä¹Ø¼ü×ÖÊÇbool£¬CÓïÑÔÖ±µ½C99±ê×¼²ÅÔö¼ÓÁ˶Բ¼¶ûÀàÐ͵ÄÖ§³Ö£¬¹Ø¼ü×ÖΪ_Bool£¬ÒòΪboolÒѾ­±»C++ÓÃÁË£¬ËùÒÔÑ¡ÁËÕâ¸öÊ®·ÖÆæ¹ÖµÄ¹Ø¼ü×Ö¡£ÔÚÕâ֮ǰC³ÌÐòÔ±¶Ô²¼¶ûÀàÐ͵ÄÄ£ÄâÊÇÏ൱»ìÂҵġ£ÎªÁËÔÚCºÍC++³ÌÐòÖÐÒÔͳһµÄ·½Ê½Ê¹Óò¼¶ûÀàÐÍ£¬Í¬Ê±Ìá¸ß¿ÉÒÆÖ²ÐÔ£¬¿ÉÒÔ²ÉÓÃÏÂÃæµÄ·½Ê½:
¹¹ÔìÒ»¸östdbool.hÍ·ÎÄ ......

C/C++´úÂëת»»¼ÓÁÁΪHTML´úÂë

½«C/C++³ÌÐò·Åµ½ÍøÂçÉϲ¢²»ÊǼòµ¥µÄ¸´ÖÆÕ³Ìù£¬´ó²¿·ÖÍøÕ¾ºÍblogÊDz»Ìṩ´úÂëµÄÖ±½ÓÕ³ÌùµÄ£¨µ±È»CSDNÊDz»´íµÄ£©£¬Ö®Ç°ÔÚsinaд²©¿ÍµÄʱºò¾ÍÅöµ½ÀàËƵÄÎÊÌâ¡£
C/C++×¥»»ÎªHTMLµÄ¹Ø¼üÊÇ´¦Àí×¢ÊÍ£¬¹Ø¼ü×Ö¡£µ±È»Ò²¿ÉÒÔ¶Ô×Ö·û´®£¬Êý×Ö½øÐÐÒ»¶¨µÄ¼ÓÁÁ´¦Àí¡£
1.ÎÒÒÔÇ°ÓÃC++д¹ýÒ»¸ö³ÌÐò£¬Æäʵ±íÃæÉÏÊÇC++£¬Ö»ÊÇÊä³öÓÃÁËcoutºÍcin¶ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ