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

CºÍC£«£«»ìºÏ±à³ÌÏà¹ØÎÊÌâ½â¾ö·½·¨

Ò» £º½â¾öC»òC++ÖеÄmultiple definition ofÎÊÌâ
server.cpp
clientp2p.cpp
#include "exception.h"
#include "clientp2p.h"
clientp2p.h
ÖÐдÓÐËùÓеÄÈ«¾Ö±äÁ¿¼°Æä³õʼ»¯Öµ
ºÍº¯ÊýÉùÃ÷
1.server.cppÖУº
ÒýÓÃ
£º
#include "clientp2p.h"
int Main(....)
{
...
}
2.clientp2p.cpp
ÖУ¬
Ò²ÒýÓÃ
£º
#include
"clientp2p.h"
....
3. file_2.cpp
#include "global.h"
...
 
G£«£«ÔÚ±àÒëµÄʱºò¾Í»á³ö´í£º
clientp2p.o:(.bss+0x0): multiple definition of `ClientList'
server.o:(.bss+0x0): first defined here
Ô­ÒòÊÇÒòΪÔÚ¶à´Î°üº¬
clientp2p
.hʱÖظ´¶¨ÒåÁ˱äÁ¿ºÍº¯Êý¡£
½â¾ö·½·¨£º
·½·¨Ò»£º
ÔÚ
clientp2p
.c£¨»ò.cpp)  ÖÐÉùÃ÷±äÁ¿£¨²»³õʼ»¯£©£¬È»ºóÍ·Îļþ
clientp2p
.hÖÐÔÚËùÓеıäÁ¿ÉùÃ÷Ç°¼ÓÉÏextern
Èç extern int flag;
È»ºóÔÚÆäËûÐèҪʹÓÃÈ«¾Ö±äÁ¿µÄ cppÎļþÖаüº¬.h Îļþ¶ø²»Òª°üº¬ .cpp Îļþ¡£±àÒëÆ÷»áΪglobal.cpp Éú³ÉÄ¿±êÎļþ£¬È»ºóÁ¬½Óʱ£¬ÔÚʹÓÃÈ«¾Ö±äÁ¿µÄÎļþÖоͻáÁ¬½Óµ½´ËÎļþ ¡£
·½·¨¶þ£º
ÔÚ
clientp2p
.hÖмÓÈë·ÀÖ¹¶à´ÎÖظ´¶¨ÒåµÄºêÅжϷûºÅ
ÄãµÄ.HÀïÃæÒª¼ÓÉÏÌõ¼þ±àÒë
#ifndef  GLOBAL
#define GLOBAL
XXXXX
XXXXX
#endif
¼Çס£ºÔÚifndefʱһ¶¨ÒªÔÚµÚÒ»ÐУ¬Ç°±ß²»ÒªÓÐÈκεÄ×¢ÊÍ»òÓï¾ä¡£
¶þ:
undefined reference to `std::ios_base::Init::Init() ½â¾ö
ÔÚlinuxϱàÒëc++ ³ÌÐòҪʹÓÃg++ ±àÒëÆ÷,Èç¹ûÄãÒªÊÇʹÓÃgcc±àÒëÆ÷¾Í»áÓÐÉÏÃæµÄ±¨´íÐÅÏ¢,Ö»ÒªÔÚÔÚgccºó¼ÓÉÏ -lstdc++¾ÍokÁË
eg:  gcc  example.c -lstdc++


Ïà¹ØÎĵµ£º

C/C++Êý×éÃûÓëÖ¸ÕëÇø±ð

 ÒÔÏÂÎÄÕÂתÔØÓÚ:ΪÁËѧϰºÍÊÕ²Ø
http://tech.163.com/school · 2005-08-23 11:05:18 · À´Ô´: Ì켫Íø
C/C++Êý×éÃûÓëÖ¸ÕëÇø±ð
¡¡¡¡ÒýÑÔ
¡¡¡¡Ö¸ÕëÊÇC/C++ÓïÑÔµÄÌØÉ«£¬¶øÊý×éÃûÓëÖ¸ÕëÓÐÌ«¶àµÄÏàËÆ£¬ÉõÖÁºÜ¶àʱºò£¬Êý×éÃû¿ÉÒÔ×÷ΪָÕëʹÓá£ÓÚÊǺõ£¬ºÜ¶à³ÌÐòÉè¼ÆÕ߾ͱ»¸ãºýÍ¿ÁË¡£¶øÐí¶àµÄ´óѧÀÏʦ£¬ËûÃÇ ......

²âÊÔ¶ÔCµÄÕÆÎճ̶È

 
ÏÂÃæÕâ¸ö³ÌÐòÊä³öʲô£¿
enum {false,true};
int main()
{
int i=1;
do
{
printf("%d\n",i);
i++;
if(i < 15)
continue;
}while(false);
return 0;
}
ÄãÏàÐÅô£¿ÏÂà ......

CÖкê#ºÍ##µÄÔËÓÃ

 #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#define f(a,b) a##b
#define g(a)  #a
#define h(a) g(a)
int main()   
{   
    char a = 'a';      
    ......

´ÓÁ½µÀ¾­µäÊÔÌâ̸C/C++ÖÐÁªºÏÌ壨union£©µÄʹÓÃ


´ÓÁ½µÀ¾­µäÊÔÌâ̸C/C++ÖÐÁªºÏÌ壨union£©µÄʹÓÃ
ÊÔÌâÒ»£º±àдһ¶Î³ÌÐòÅжÏϵͳÖеÄCPUÊÇLittle endian»¹ÊÇBig endianģʽ£¿
·ÖÎö£º
×÷Ϊһ¸ö¼ÆËã»úÏà¹ØרҵµÄÈË£¬ÎÒÃÇÓ¦¸ÃÔÚ¼ÆËã»ú×é³ÉÖж¼Ñ§Ï°¹ýʲô½ÐLittle endianºÍBig endian¡£Little endianºÍBig endianÊÇCPU´æ·ÅÊý¾ÝµÄÁ½ÖÖ²»Í¬Ë³Ðò¡£¶ÔÓÚÕûÐÍ¡¢³¤ÕûÐ͵ÈÊý¾ÝÀàÐÍ£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ