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

¹ØÓÚ extern "C"

µ±Õâ¸öÊÀ½ç»¹Ö»ÓÐCµÄʱºò£¬ÊDz»ÐèÒªextern "C"µÄ¡£
µ«ÊÇ£¬µ±C++³öÏÖÖ®ºó£¬ÓÐʱºò£¬ÎÒÃǾÍÐèÒªextern "C"ÁË¡£
ÄǾ¿¾¹ÊÇÔÚʲôÑùµÄÇé¿öÏ£¬ÎÒÃÇÐèÒªÓÃextern "C"ÄØ£¿
ÓÐÈË˵£¬ÊÇΪÁËCÄܹ»µ÷ÓÃC++£¬ÓÐÈË˵ÊÇΪÁËÔÚC++ÖÐÄܵ÷ÓÃCµÄ¿âº¯Êý¡£ÊDz»ÊÇ°ÑÄãŪºýÍ¿ÁË£¿
ÏÈ˵˵extern "C"ÊÇɶ×÷Óðɡ£
extern "C" ÊǸæËßC++±àÒëÆ÷£¬Õâ¸öº¯ÊýÊÇÍêÈ«¼æÈÝCµÄ£¬²»°üº¬C++ÓжøCÖÐûÓеÄÌØÐԵġ£²¢ÇÒ¸æËß±àÒëÆ÷£¬ÔÚÉú³ÉÄ¿±êÎļþµÄʱºò£¬Ê¹ÓÃCµÄ·½Ê½Éú³Éº¯ÊýÃû¡£
ÉÏÃæÕâ¾ä»°ÓÐÁ½¸öÖص㣬
µÚÒ»ÊÇ extern "C" Ö»ÓÐ C++±àÒëÆ÷Èϵã¬C±àÒëÆ÷ÊDz»ÈÏʶµÄ¡£
µÚ¶þÊÇ ÓÃCµÄ·½Ê½Éú³Éº¯ÊýÃû¡£Ê²Ã´½Ð "ÓÃCµÄ·½Ê½Éú³Éº¯ÊýÃû"£¿ C++±àÒëÆ÷ºÍC±àÒëÆ÷Éú³Éº¯ÊýÃûµÄ·½Ê½ÊDz»Í¬µÄ¡£ÒòΪC++ÒªÖ§³Öº¯ÊýÖØÔØ£¬ËùÒÔC++±àÒëÆ÷ÔÚÉú³Éº¯ÊýÃûµÄʱºò»á°Ñº¯Êý²ÎÊýµÄÀàÐͼÓÔÚº¯ÊýÃûÖС£¶øC±àÒëÆ÷¾Í±È½Ï¼òµ¥£¬Ö±½ÓÔÚº¯ÊýÃû×ÖÇ°¼ÓÒ»¸öÏ»®Ï߸㶨¡£
±ÈÈç void foo( int x ); ÕâÑùµÄº¯Êý
C±àÒëÆ÷±àÒë³öÀ´ÔÚ·ûºÅ¿âÖеÄÃû×ÖÊÇ_foo£¬¶øC++±àÒëÆ÷±àÒë³öÀ´ÔÚ·ûºÅ¿âÖеÄÃû×Ö¿ÉÄÜÊÇ _foo_int ÕâÑùµÄ¡£
ÄÇôʹÓà extern "C" ÓÐʲôÒâÒåÄØ£¿
ÎÒ¾õµÃ ”ΪÁËC++ÖÐÄܵ÷ÓÃCµÄ¿âº¯Êý“ ÕâÑùµÄ˵·¨ÊÇÕýÈ·µÄ¡£
Ϊʲô£¿
¿¼ÂÇÏÂÃæµÄÇé¿ö£¬ÄãÓÐÒ»¸öCʵÏֵĿ⣬²¢ÓÃC±àÒëÆ÷±àÒëÉú³É¿âÎļþ¡£
¼ÙÉèÕâ¸ö¿âÀïÓÐÒ»¸öº¯ÊýΪ void foo( int );
ÔÚC++µÄij¸öÀàÖУ¬ÄãÒªÓÃÕâ¸öfooº¯Êý£¬ÄãÔÚC++Ô´ÎļþÖÐÓÃ
extern void foo( int );
ÒýÈë¡£
ÕâÑùÔÚÁ´½ÓµÄʱºò³ö´íÁË¡£
ÒòΪC++±àÒëÆ÷ÔÚ±àÒëC++Ô´ÎļþµÄʱºò£¬ÈÏΪvoid foo( int ); ÔÚ·ûºÅ±íÖÐÓ¦¸ÃÊÇ
_foo_int Õâ¸öÑù×ӵġ£¶øÔÚÁ´½ÓµÄʱºòÕÒ²»µ½_foo_int£¬Ö»ÓÐ_foo¡£ËùÒÔÁ´½Ó³ö´íÁË¡£
Ôõô½â¾öÄØ£¿
extern void foo( int );
¸Ä³É
extern "C" void foo( int );
¾ÍÐÐÀ²¡£
Èç¹ûÊÇÖ±½Óinclude CµÄÍ·ÎļþµÄ£¬ÄÇ¿ÉÒÔÕâÑù
extern "C" {
#include "HeaderOfC.h"
}
ÕâÑùC++±àÒëÆ÷¾ÍÖªµÀ£¬Õâ¸öfooÊÇCµÄº¯Êý£¬Éú³ÉÃû×ÖµÄʱºò²»ÐèÒª´ø²ÎÊý¡£ÕâÑùÁ´½ÓµÄʱºò¾ÍûÎÊÌâÀ²¡£
ÄÇôÔÚ½ñÌ죬ÎÒÃÇдһ¸öCµÄ¿âµÄʱºò£¬µ±È»´æÔÚÎÒÃǵĿⱻC++µÄ³ÌÐòËùʹÓõĿÉÄÜÐÔ¡£
ÎÒÃDz»Ï£ÍûÔÚC++µÄÔ´ÂëÖÐÒýÓÃÎÒÃǵÄÍ·ÎļþµÄʱºò»¹Òª
extern "C" {
#include "yourlib.h"
}
ÕâôÂé·³¡£
ËùÒÔÎÒÃÇÔÚдCµÄ¿âµÄÍ·ÎļþµÄʱºòÖ÷¶¯µÄ¼ÓÉÏÁË extern "C"¡£
µ«ÕâÀïÓÐÒ»¸öÎÊÌ⣬ÒòΪC±àÒëÆ÷²»ÈÏʶextern "C"°¡£¬ËùÒÔ¾ÍÓÐÁË
ºê __cplusplus
¶ÔÓÚC±àÒëÆ÷£¬Ã»Óж¨ÒåÕâ¸öºê£¬¶øC++±àÒëÆ÷¶¨ÒåÁËÕâ¸ö


Ïà¹ØÎĵµ£º

CÖ¸ÕëÒÜÏë

Ö¸Õë,ÖÚËùÖÜÖª,ʱΪһÄÚ´æµØÖ·.Å׿ªOS¼¶±ð»ò¸üµÍµÄÓ²¼þ¼¶±ð²»Ëµ,½ö¶ÔÓ¦ÓÃÄÚµÄʹÓýøÐÐССµÄÒܲâÌÖÂÛ.
Ê×ÏÈ,ÔÚÓ¦ÓÃÄÚ,ÓÃmallocÉêÇëµ½µÄÒ»¿éµØÖ·Ó¦¸ÃÊÇÁ¬ÐøµÄ(²Â²â,Âß¼­ÉÏÁ¬Ðø,ʵ¼ÊÉÏÎïÀíÈçºÎ·Ö²¼²»Óè¹Ø×¢).
Æä´Î,Êý¾Ý´æÔÚÔÚÄÚ´æÖж¼ÊÇÒÔ2½øÖÆÐÎʽ´æ·Å.²»´æÔÚÊý¾ÝÀàÐÍ,Òò´Ë,¶ÔÄÚ´æÊý¾ÝµÄ²Ù×÷,Ö»Òª×ñÑ­½ø³öÀàÐÍÒ»Ö¼´¿É.
´ ......

C/C++ ѧϰ±Ê¼Ç[03].È¥µôC·ç¸ñµÄ×¢ÊÍ

ÍøÉÏËÑË÷ÁËÒ»´ó¶ÑÈ¥µô/*ºÍ*/Ö®¼ä×¢Ê͵ĴúÂë,¾ÍÏñ<The C Programming Language>Á·Ï°1-23ÀïÓÐÈË˵µÄÒ»Ñù
´ó²¿·Ö¶¼»á±»ÒÔϵijÌÐòbroken,Õâ¸ö¹¦ÄÜ¿´ÆðÀ´¼òµ¥,ʵ¼ÊÉϺÜÓÐÄѶÈ.ÍøÉÏʵÏֵĴúÂë,³ýÁËÎÒÕÒµ½µÄÒ»¸öÓÃÎļþÖ¸ÕëʵÏÖµÄûÓÐÎÊÌâÍâ,ÆäÓàµÄ¶¼´æÔÚ¸÷ÖÖbug,²»ÐŵĻ°¾ÍÓÃÒÔϵijÌÐò²âÊÔÒ»ÏÂ:-),µ±È»Õâ¸ö³ÌÐòÒ²²»¹»ÍêÉÆ ......

ʹÓÃCÓïÑÔÀ©Õ¹Python(Îå)

ÉÏһƪÖÐÎÒÃÇÔÚpython¶ËµÄ×ö·¨ÊÇÿ´Î¶ÁÈ¡Ò»¸öÊý¾Ý¿é£¬È»ºó½«Õâ¸öÊý¾Ý¿é´«µÝ½øCÀ©Õ¹Ä£¿éÖÐÈ¥£¬µ«¶ÔÓÚÄ¿±êÎļþµÄÊý¾ÝдÈëÊÇÔÚCÀ©Õ¹Ä£¿éÖÐÍê³ÉµÄ£¬µ«Æäʵ¿ÉÒÔ¸üÃæÏò¶ÔÏóÒ»µã£¬²»ÊÇÂð£¿Ô­À´outfpÊÇÒ»¸öÎļþÖ¸Õ룬²»Èç¸Ä³ÉÒ»¸ö´ÓPythonÖд«µÝÒ»¸öÎļþ¶ÔÏóµ½CÄ£¿éÀïÈ¥£¬Õâ¸öÎļþ¶ÔÏóÓÐ×Ô¼ºµÄwrite·½·¨£¬ÕâÑùÔÚCÀ©Õ¹Ä£¿éÖÐÄã¾Í¿ÉÒÔ ......

Óà Eclipse ¿ª·¢C/C++

ÒªÏëÓÃeclipse¿ª·¢C/C++ Ê×ÏÈÒªÅäÖÃÒ»¸öC/C++µÄ±àÒë»·¾³£¬ÒòΪeclipse×ÔÉíÊDz»´øµÄ¡£ ÐèÒªÏÂÃæÕâÁ½¸ö±Ø²»¿ÉÉٵŤ¾ß 1.±àÒ빤¾ß MinGW£ºhttp://www.mingw.org/             Ö±½ÓÏÂÔصØÖ·£ºhttp://sourceforge.net/projects/mingw/files/ 2.eclipse²å¼þ CDT £ ......

ǶÈëʽCÃæÊÔÌâ1

1 . ÓÃÔ¤´¦ÀíÖ¸Áî#define ÉùÃ÷Ò»¸ö³£Êý£¬ÓÃÒÔ±íÃ÷1ÄêÖÐÓжàÉÙÃ루ºöÂÔÈòÄêÎÊÌ⣩
         #define SECONDS_PER_YEAR (60 * 60 * 24 * 365)UL
ÎÒÔÚÕâÏë¿´µ½¼¸¼þÊÂÇ飺
1) #define Óï·¨µÄ»ù±¾ÖªÊ¶£¨ÀýÈ磺²»ÄÜÒԷֺŽáÊø£¬À¨ºÅµÄʹÓ㬵ȵȣ©
2)¶®µÃÔ¤´¦ÀíÆ÷½«ÎªÄã¼ÆËã³£Êý±í´ï ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ