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

C/C++ÖÐÖظ´¶¨ÒåµÄÎÊÌâ


ÓÃ#include¿ÉÒÔ°üº¬ÆäËûÍ·ÎļþÖбäÁ¿¡¢º¯ÊýµÄÉùÃ÷£¬ÎªÊ²Ã´»¹Òªextern¹Ø¼ü×Ö,Èç¹ûÎÒÏëÒýÓÃÒ»¸öÈ«¾Ö±äÁ¿»ò
º¯Êýa£¬ÎÒÖ»ÒªÖ±½ÓÔÚÔ´ÎļþÖаüº¬#include<xxx.h>
(xxx.h°üº¬ÁËaµÄÉùÃ÷)²»¾Í¿ÉÒÔÁËô£¬ÎªÊ²Ã´»¹ÒªÓÃexternÄØ£¿£¿Õâ¸öÎÊÌâÒ»Ö±Ò²ÊÇËÆÊǶø·ÇµÄÀ§ÈÅ×ÅÎÒÐí¶àÄêÁË£¬½ñÌìÉÏÍøºÝºÝ²éÁËÒ»ÏÂ×ÜËãСÓÐ
Ëù»ñÁË£º
Í·Îļþ
Ê×ÏÈ˵ÏÂÍ·Îļþ£¬ÆäʵͷÎļþ¶Ô¼ÆËã»ú¶øÑÔûʲô×÷Óã¬ËýÖ»ÊÇÔÚÔ¤±à
ÒëʱÔÚ#includeµÄµØ·½Õ¹¿ªÒ»Ï£¬Ã»±ðµÄÒâÒåÁË£¬ÆäʵͷÎļþÖ÷ÒªÊǸø±ðÈË¿´µÄ¡£
ÎÒ×ö¹ýÒ»¸öʵÑ飬½«Í·ÎļþµÄºó׺¸Ä³Éxxx.txt£¬È»ºóÔÚÒýÓøÃÍ·ÎļþµÄµØ·½ÓÃ
#include"xxx.txt"
±àÒ룬Á´½Ó¶¼ºÜ˳ÀûµÄ¹ýÈ¥ÁË£¬ÓÉ´Ë¿ÉÖª£¬Í·Îļþ½ö½öΪÔĶÁ´úÂë×÷Óã¬Ã»ÆäËûµÄ×÷ÓÃ
ÁË£¡
²»¹ÜÊÇC»¹ÊÇC++£¬Äã°ÑÄãµÄº¯Êý£¬±äÁ¿»òÕ߽ṹÌ壬ÀàɶµÄ·ÅÔÚÄãµÄ.c»òÕß.cppÎļþÀȻºó±àÒë³É
lib,dll,obj,.oµÈµÈ£¬È»ºó±ðÈËÓõÄʱºò ×î»ù±¾µÄgcc hisfile.cpp yourfile.o|obj|dll|lib µÈµÈ¡£
µ«
¶ÔÓÚÎÒÃdzÌÐòÔ±¶øÑÔ£¬ËûÃÇÔõô֪µÀÄãµÄlib,dll...ÀïÃæµ½µ×ÓÐʲô¶«Î÷£¿Òª¿´ÄãµÄÍ·Îļþ¡£ÄãµÄÍ·Îļþ¾ÍÊǶÔÓû§µÄ˵Ã÷¡£º¯Êý£¬²ÎÊý£¬¸÷ÖÖ¸÷ÑùµÄ½Ó
¿ÚµÄ˵Ã÷¡£
   
ÄǼÈÈ»ÊÇ˵Ã÷£¬ÄÇôͷÎļþÀïÃæ·ÅµÄ×Ô
È»¾ÍÊǹØÓÚº¯Êý£¬±äÁ¿£¬ÀàµÄ“ÉùÃ÷
”ÁË¡£¼Ç×Å£¬ÊÇ“ÉùÃ÷”£¬
²»ÊÇ“¶¨Ò唡£
ÄÇô£¬ÎÒ¼ÙÉè´ó¼ÒÖªµÀÉùÃ÷ºÍ¶¨ÒåµÄ
Çø±ð¡£ËùÒÔ£¬×îºÃ²»ÒªÉµÎûÎûµÄÔÚÍ·ÎļþÀﶨÒåʲô¶«Î÷¡£±ÈÈçÈ«¾Ö±äÁ¿£º
/*xxÍ·Îļþ*/
#ifndef _XX_Í·Îļþ.H
#define _XX_Í·Îļþ.H
int A;
#endif
ÄÇô£¬ºÜÔã¸âµÄÊÇ£¬ÕâÀïµÄint
AÊǸöÈ«¾Ö±äÁ¿µÄ¶¨Ò壬ËùÒÔÈç¹ûÕâ¸öÍ·Îļþ±»¶à´ÎÒýÓõĻ°£¬ÄãµÄA»á±»Öظ´¶¨Òå
ÏÔÈ»Óï·¨ÉÏ´íÁË¡£Ö»²»¹ýÓÐÁËÕâ¸ö#ifndefµÄÌõ¼þ±àÒ룬ËùÒÔÄܱ£Ö¤ÄãµÄÍ·ÎļþÖ»±»ÒýÓÃÒ»
´Î£¬²»¹ýÒ²Ðí»¹ÊÇ»á²í×Ó£¬µ«Èô¶à¸öcÎļþ°üº¬Õâ¸öÍ·Îļþʱ»¹ÊÇ»á³ö´íµÄ£¬ÒòΪºêÃûÓÐЧ·¶Î§½öÏÞÓÚ±¾cÔ´Îļþ£¬ËùÒÔÔÚÕâ¶à¸öcÎļþ±àÒëʱÊDz»»á³ö´íµÄ£¬µ«ÔÚ
Á´½Óʱ¾Í»á±¨´í£¬ËµÄã¶à´¦¶¨ÒåÁËͬһ¸ö±äÁ¿£¬
Linking...
incl2.obj : error
LNK2005: "int glb" (?glb@@3HA
) already
defined in incl1.obj
Debug/incl.exe : fatal error LNK1169: one
or more multiply defined symbols found
×¢Ò⣡£¡£¡
extern
Õâ¸ö¹Ø¼ü×Ö
ÕæµÄ±È½Ï¿É¶ñ£¬ÔÚÉùÃ÷µÄʱºò£¬Õâ¸öextern¾ÓÈ»¿ÉÒÔ±»Ê¡ÂÔ£¬ËùÒÔ»áÈÃÄã¸ã²»Çå³þµ½µ×ÊÇÉùÃ÷»¹ÊǶ¨Ò壬ÏÂÃæ·Ö±äÁ¿ºÍ


Ïà¹ØÎĵµ£º

ʹÓÃCÓïÑÔÀ©Õ¹Python£¨Ò»£©

¿ª·¢»·¾³£ºUbuntu9.10,python2.6,gcc4.4.11,ubuntuϵÄpythonÔËÐаüºÍ¿ª·¢°üÊÇ·Ö¿ªµÄ£¬Òò´ËÐèÒªÔÚÐÂÀûµÃÀïÃæ°²×°python-all-dev,´Ó¶ø¿ÉÒÔÔÚ´úÂëÖÐÒýÓÃpythonµÄÍ·ÎļþºÍ¿â¡£2.ÏÂÃæÊÇÒ»¸ö×î¼òµ¥µÄ¿ÉÒÔ¹©pythonµ÷ÓõÄcÀ©Õ¹Ä£¿é£¬¼ÙÉèc³ÌÐòÎļþÃûΪfoo.c:´úÂë#include <Python.h>
static PyObject* foo_b ......

symbian Open C and Open C++ Ïà¹Ø

nokia wiki£ºhttp://developer.symbian.org/wiki/index.php/Open_C_and_Open_C%2B%2B_Technical_Overview/zh-hans
symbianÉÏ¿ª·¢opencʱÐèҪעÒâµÄÎÊÌâ
http://blog.csdn.net/sizhiguo/archive/2009/05/21/4206138.aspx
µÚÒ»£ºÈçprintf¡¢sprint¡¢Îļþ²Ù×÷¡¢socket²Ù×÷µÈ£¬Ä£ÄâÆ÷ÆÁÄ»¶¼»á³öÏÖ°×ÆÁµÈ´ý£¬²¢ÇÒÊÇÒ»Ö±ÏÂÈ¥¡£ ......

C Traps and Pitfalls ¶ÁÊéÕª¼Ç

Óõ¥ÒýºÅÒýÆðµÄÒ»¸ö×Ö·ûʵ¼ÊÉÏ´ú±íÒ»¸öÕûÊý£¬ÕûÊýÖµ¶ÔÓ¦ÓÚ¸Ä×Ö·ûÔÚ±àÒëÆ÷²ÉÓõÄ×Ö·û¼¯ÖеÄÐòÁÐÖµ¡£
ÓÃË«ÒýºÅÒýÆðµÄ×Ö·û´®£¬´ú±íµÄÊÇÒ»¸öÖ¸ÏòÎÞÃûÊý×éÆðʼ×Ö·ûµÄÖ¸Õ룬¸ÃÊý×鱻˫ÒýºÅÖ®¼äµÄ×Ö·ûÒÔ¼°Ò»¸ö¶îÍâµÄ¶þ½øÖÆֵΪÁãµÄ×Ö·û'\0'³õʼ»¯¡£
printf("Hello world\n");
Óë
char hello[] = {'H', 'e', 'l', 'l', 'o', ' ' ......

"extern C", ÄãÕæµÄ¶®ÁËÂð£¿

       ÔÚc++ primeÊéÖп´µ½¹ý£¬ÔÚDLLºÍlibÖп´µ½¹ý£¬µ«ÊÇÿ´Î¿´¹ý¾Í²»ÇóÉõ½âµØһɨ¶ø¹ý¡£ÐÄÀïÖªµÀÓÐextern cÕâ¸öÓï¾ä£¬È´²»ÖªµÀ¸ÃÓÃÔÚÄÄÀÓÖÄÜÆðµ½Ê²Ã´×÷Óᣰ¦£¬ÏëÏë×Ô¼ºÒ²ËãÊÇд¹ý²»ÉÙCODEµÄÈËÁË£¬¿ÉÕâÖÖÑÛ¸ßÊֵ͵Ä벡ȴ´Óû¸Ä±ä¹ý¡£½ñÌìͻȻÏëÆðexternÕâ¸ö¹Ø¼ü×Ö£¬Ëì¾ö¶¨²»ÄÜÔÙÕâôÀË ......

CÖÐÈçºÎµ÷ÓÃC++£¿C++ÖÐÈçºÎµ÷ÓÃC

CÖÐÈçºÎµ÷ÓÃC++£¿C++ÖÐÈçºÎµ÷ÓÃC?Õâ¸öÎÊÌâÊÇÐí¶àÈí¼þ¹«Ë¾ÃæÊÔ¹ý³ÌÖлáÎʵ½µÄÒ»¸ö³£¼ûÎÊÌâ¡£»Ø´ðÕâ¸öÎÊÌâ²¢²»À§ÄÑ£¬ÄǾÍÊÇʹÓÃ
extern "C",µ«ÊÇÃæÊÔ¹Ù¿ÉÄÜÏëͨ¹ýÕâ¸öÎÊÌâÁ˽âÄã¶ÔC/C++ÕÆÎյij̶ȡ£ÏÂÃæ×Ðϸ·ÖÎö¸ÃÎÊÌâ¡£
    Ê×ÏÈ£¬×÷
ΪexternÊÇC/C++ÓïÑÔÖбíÃ÷º¯ÊýºÍÈ«¾Ö±äÁ¿×÷Ó÷¶Î§£¨¿ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ