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++
Ïà¹ØÎĵµ£º
2009-07-26 15:50
½ñÌìÇÞÊÒµÄɽ¶«ÐÖµÜÔÚÁ·¶þ¼¶µÄÉÏ»ú£¬ÆäÖÐÒ»¸öÌâÄ¿´ó¸ÅÊÇÕâÑù£ºÔÚÒ»¸öº¯ÊýÖУ¬ÓÐÒ»¸öÖ¸ÕëÐβΣ¬¼ÇΪ*p£¬È»ºóÔÚº¯ÊýÄÚ²¿¶¨ÒåÁËÁÙʱ±äÁ¿a,aºÍ*pÊÇͬÖÖÀàÐÍ¡£¾¹ýһϵÁмÆËã £¬aµÃµ½ÁËÒ»¸öÖµ£¬Õâ¸öÖµ×îºóÊÇÐèÒª¼Ç¼ÔÚÖ¸Õë*pÀïÃæµÄ£¬Ó¦¸ÃÔõô±£´æÄØ£¿ÎÒµ±Ê±Ëæ±ã¾Í˵£¬p=&a¡£½á¹û·¢Éú´íÎóÁË£¬Ã»Óе ......
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int main(){
int sockfd;
int len;
struct sockaddr_in address;
int result;
char *strings="GET /svnup/rewrite.php HTTP/1 ......
4*4¼üÅÌɨÃèC³ÌÐò
#include<reg52.h>
#define uchar unsigned char
uchar code table[]={0xC0,0xF9,0xA4,0xB0,0x99,
0x92,0x82,0xF8,0x80,0x90,
0x88,0x83,0xC6,0xA1,0x86,0x8E};
uchar temp,num;
void display(uchar);
void delay(uchar a)
{
......
ÏÂÃæÕâ¸ö³ÌÐòÊä³öʲô£¿
enum {false,true};
int main()
{
int i=1;
do
{
printf("%d\n",i);
i++;
if(i < 15)
continue;
}while(false);
return 0;
}
ÄãÏàÐÅô£¿ÏÂà ......
//linuxϱàÒëg++ $(mysql_config --cflags) ***.cpp $(mysql_config --libs)
/*mysqlÊý¾Ý¿âÖбíµÄÄÚÈÝ
mysql> select * from maindb;
+------------------+---------+-------------+---------+----------+---------------------+---------------------+---------------------+------------------- ......