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

extern "C"

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"ʱ»á³öÏÖ±àÒëÓï·¨´íÎó¡£
&n


Ïà¹ØÎĵµ£º

¹ØÓÚ extern "C"

µ±Õâ¸öÊÀ½ç»¹Ö»ÓÐCµÄʱºò£¬ÊDz»ÐèÒªextern "C"µÄ¡£
µ«ÊÇ£¬µ±C++³öÏÖÖ®ºó£¬ÓÐʱºò£¬ÎÒÃǾÍÐèÒªextern "C"ÁË¡£
ÄǾ¿¾¹ÊÇÔÚʲôÑùµÄÇé¿öÏ£¬ÎÒÃÇÐèÒªÓÃextern "C"ÄØ£¿
ÓÐÈË˵£¬ÊÇΪÁËCÄܹ»µ÷ÓÃC++£¬ÓÐÈË˵ÊÇΪÁËÔÚC++ÖÐÄܵ÷ÓÃCµÄ¿âº¯Êý¡£ÊDz»ÊÇ°ÑÄãŪºýÍ¿ÁË£¿
ÏÈ˵˵extern "C"ÊÇɶ×÷Óðɡ£
extern "C" ÊǸæËßC++±àÒëÆ÷£¬ ......

fork compare to exec in linux c program

pid_t  pid=fork()
it has 3 situation for the return result pid
0  child
>0 parent process
<0 fork fail
fork create a new process  and it parent live alse when the child process had been created ......

ÒÀÈ»CÄÚ´æ

Ò». ÔÚcÖзÖΪÕ⼸¸ö´æ´¢Çø
1.Õ» - ÓɱàÒëÆ÷×Ô¶¯·ÖÅäÊÍ·Å
2.¶Ñ - Ò»°ãÓɳÌÐòÔ±·ÖÅäÊÍ·Å£¬Èô³ÌÐòÔ±²»ÊÍ·Å£¬³ÌÐò½áÊøʱ¿ÉÄÜÓÉOS»ØÊÕ
3.È«¾ÖÇø£¨¾²Ì¬Çø£©£¬È«¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿µÄ´æ´¢ÊÇ·ÅÔÚÒ»¿éµÄ£¬³õʼ»¯µÄÈ«¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿ÔÚÒ»¿éÇøÓò£¬Î´³õʼ»¯µÄÈ«¾Ö±äÁ¿ºÍδ³õʼ»¯µÄ¾²Ì¬±äÁ¿ÔÚÏàÁÚµÄÁíÒ»¿éÇøÓò¡£- ³ÌÐò½áÊøÊÍ·Å
4.ÁíÍ ......

Linux C ʵÏÖÏ̳߳Ø

×î½ü×öµÄһЩ¹¤×÷ÐèÒªÓõ½Ï̳߳ؼ¼Êõ£¬Òò´Ë²Î¿¼ÁËһЩ×ÊÁϺÍÊé¼®£¬È硶0bug c/c++ÉÌÓù¤³ÌÖ®µÀ¡·¡£
Ϊ´ËÔÚlinuxƽ̨ÉÏÓô¿cдÁËÒ»¸öÏ̳߳صÄʵÏÖ¡£
ÔÚ´ËÁгöÁËÔ­´úÂë¡£
Ö÷ÒªÓõ½µÄÊý¾Ý½á¹¹ÓÐ
1.struct  thread_pool_t    // thread pool µÄʵÏÖ´úÂë
2.struct thread_pool_token_t  &nb ......

s3c2410 RTCÇý¶¯¿ò¼ÜlinuxÄÚºËÔ´Âë·ÖÎö

ʵÔÚÎÞÁÄÖоͽ«Ô­À´µÄһЩ¶«Î÷ÕûÀíÁËһϣ¬×Ô¼ºÊǸö¼ÇÐÔ²»ºÃµÄÈË£¬¸ô¶Ïʱ¼äÕûÀí×Ô¼º£¬Í¬Ê±Ò²Ï£Íû¿ÉÒÔ·½±ãËûÈË¡£
----------------------------------------------------------------------------------------------------------------------------------------
/**//*************************************************** ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ