C/C++ÄÚ´æ¹ÜÀíÖ®ÄÚ´æй©¼ì²é
Ò»£® ¸ÅÊö
ÄÚ´æй©һֱÊÇÈí¼þ¿ª·¢ÈËÔ±×îÍ·´óµÄÎÊÌâÖ®Ò»£¬ÓÈÆäÏñC/C++ÕâÑù×ÔÓɶȷdz£´óµÄ±à³ÌÓïÑÔ£¬¼¸ºõÊÇÿһ¸öÓÃÆ俪·¢³öÀ´µÄÈí¼þ¶¼»á³öÏÖÄÚ´æй©µÄÇé¿ö¡£
Èç¹ûûÓÐÄÚ´æй©£¬ÊÀ½ç»òÐí»á±äµÄÃÀºÃ¡£È»¶ø£¬ÍêÈ«ÃÀºÃµÄÊÀ½çÊDz»´æÔڵģ¬ÎÒÃÇÄÜ×öµÄ¾ÍÊǾ¡Á¿ÈÃËü±äµÄ¸üÃÀºÃ¡£
¶þ£® ¹¤¾ß½éÉÜ
×ݹÛÄ¿Ç°ÊÐÃæÉÏÓв»ÉÙÄÚ´æй©¹¤¾ß£¬ÔÚÕâÀï¾Í²»¶à×ö½éÉÜ¡£±ÊÕß×î³£ÓõÄÊÇIBM¹«Ë¾³ö²úµÄIBM Rational Purify£¬ËµÆðPurifyÕⶫÎ÷£¬Îȶ¨ÐÔËäÈ»²»ÔõôÑù£¬µ«¹¦ÄܺÜÇ¿´ó¡£ËüÊÇIBM Rational PurifyPlus²úÆ·×éÖÐÈý½£¿ÍµÄÒ»Ô±¡£
PurifyÊÇÃæÏòC/C++, VB, JavaÓïÑÔ£¬²âÊÔÄÚ´æ´íÎó£¬Windows API·ÃÎÊ´íÎó£¬COM·½·¨µ÷ÓÃÇé¿öµÈ¡£
ͼ1. PurifyÖ÷½çÃæ
Purify¶ÔÓÚC/C++µÄ·ÖÎöÖ§³ÖÔ´´úÂ뼶£¬»òͨ¹ýÆäרÀû¼¼Êõ£º“Ä¿±ê´úÂë²åÈ루Object Code Insertion£©”¹¤×÷ÔÚÎÞÔ´´úÂ뼶¡£PurifyµÄ¹¦ÄÜÆäʵ·Ç³£Ö®Ç¿´ó£¬´Ë´ÎÎÒÃÇÖ»ÌÖÂÛÔõôͨ¹ýPurify½øÐÐC/C++ϵÄÄÚ´æй©·¢ÏÖ¡£ÔÚ½éÉÜËüµÄ¹¤×÷Á÷³ÌÇ°£¬ÎÒÃÇÀ´ÈÏʶһϼ¸¸öËõдÊõÓïµÄÒâ˼£º
l ABR£º Array Bounds Read£¬Êý×éÔ½½ç¶Á
l ABW£ºArray Bounds Write£¬Êý×éÔ½½çд
l FMR£ºFree Memory Read£¬¿Õ¼äÄÚ´æ¶ÁÈ¡
l IPR£º Invalid Pointer Read£¬ÎÞЧָÕë¶ÁÈ¡
l IPW£ºInvalid Pointer Write£¬ÎÞЧָÕëдÈë
l NPR£ºNull Pointer Read£¬¿ÕÖ¸Õë¶ÁÈ¡
l NPW£ºNull Pointer Write£¬¿ÕÖ¸ÕëдÈë
l UMR£ºUninitialized Memory Read£¬Î´³õʼ»¯ÄÚ´æÔĶÁ
l MLK£ºMemory leaks£¬ÄÚ´æй©
l MIU£ºMemory in use, ÄÚ´æʹÓÃÖÐ
l MPK£ºPotential memory leaks£¬Ç±ÔÚµÄÄÚ´æй©
µ±ÎÒÃÇÍê³ÉÁËÄ¿±ê´úÂ룬Éú³É¿ÉÖ´ÐгÌÐòÎļþºó£¬ÔÚPurifyÖмÓÔØËü£¬±ã¿É×Ô¶¯Íê³É¿ÉÖ´ÐгÌÐò½âÎö£¬ÔËÐУ¬·ÖÎöµÄÒ»Ó¦¹¤×÷¡£
ͼ2. Rational PurifyµÄ¹¤×÷Á÷³Ì
Èý£® й©³¡¾°¼°¼ì²â
ÏÖÔÚ£¬ÎÒÃǾÍÀ´×ö¼¸¸ö°¸Àý£¬¿´¿´Ð§¹ûÈçºÎ¡£¿ªÊ¼Ö®Ç°£¬ÏȽéÉÜһϱÊÕߵŤ×÷¼°²âÊÔ»·¾³£º
l Microsfot Windows XP Tablet PC Edition 2005 SP3
l 3GÄÚ´æ(ÔÙ¶àµÄÄÚ´æÒ²ÅÂй©J)
l Microsfot Visual Studio 2005
l IBM Rational Purify 7.0
ÔÚÕâÀïÏë¶îÍâµÄ˵Ã÷һϣ¬±ÊÕßÔø¾²âÊԶԱȹýVC2005ºÍVC6Éú³É³ÌÐò£¬·¢ÏÖVC2005Éú³É»ã±à´úÂëÖÊÁ¿±ÈVC6µÄº
Ïà¹ØÎĵµ£º
C/S¼Ü¹¹µÄÓŵãÈçÏ£º
£¨1£©C/S¼Ü¹¹µÄ½çÃæºÍ²Ù×÷ÊÖÊÆ¿ÉÒÔËæ×Å¿Í»§µÄÒªÇó½øÐж¨ÖÆ£¬¿ÉÒÔʵÏֵķdz£Æ¯ÁÁ£¬ÓÉÓÚÅÖ¿Í»§¶Ë½¨Á¢ÔÚÓ¦ÓõĻù´¡ÉÏ£¬Òò´Ë²»»áÓÉÓÚƯÁÁµÄ½çÃæ¶øÓ°Ïìʵ¼ÊµÄ²Ù×÷¡£
£¨2£©ÏµÍ³°²È«ÐÔÄÜ¿ÉÒԵõ½ºÜºÃµÄ±£Ö¤£¬ÊµÏÖ¶à²ãÈÏÖ¤Ò²²»À§ÄÑ¡£
£¨3£©C/S½á¹¹µÄϵͳÓÉÓÚÖ»ÓÐÒ»²ã½»»¥£¬Òò´ËÏìÓ¦Ëٶȷdz£¿ì¡£
C/S¹¹¼ÜµÄÈ ......
²âÊÔ´úÂëÒ»£¨VC6.0¡¢C-code£©£º
#include <stdio.h>
void main()
{
int aa;
unsigned char j1,j2;
aa=j1=j2=0;
aa=49;
j1=aa;
printf("j1=%d \n",j1);
j2=aa;
printf("j2=%c \n",j2);
}
¡¾·ÖÎö¡¿£º
[1]ÕýÈçËùÏëÏóµÄÊä³ö½á¹û£º
j1 ......
Ò»¡¢¿ª·¢»·¾³
1¡¢ windowsXP
2¡¢ mysql 5.0.22
3¡¢ Dev-C++ 4.9.9.2
4¡¢ ÏÂÔØ(mysqlpp-2.3.2-gcc3.4.2-1due.DevPak)
5¡¢ MySQL.DevPak ÏÂÔصØÖ·£º http://downloads.sourceforge.net/dev-cpp/MySQL.DevPak
6¡¢ ÏÂÔØÒÔºóͨ¹ý‘¹¤¾ß[T]’ --> ´ò ......
1.ÇóÏÂÃ溯ÊýµÄ·µ»ØÖµ£¨Î¢Èí£©
int func(x)
{
int countx = 0;
while(x)
{
countx
++;
x = x&(x-1);
}
return countx;
}
¼Ù¶¨x = 9999¡£ ´ð°¸£º8
˼·£º½«xת»¯Îª2½øÖÆ£¬¿´º¬ÓеÄ1µÄ¸öÊý¡£
2. ʲôÊÇ“ÒýÓÔ£¿ÉêÃ÷ºÍʹÓÓÒýÓÔҪעÒâÄÄЩÎÊÌ⣿
´ð£ºÒýÓþÍÊÇij¸öÄ¿±ê±äÁ¿µÄ&l ......
VC++ÓëJava
Visual C++ 6.0ÊÇ΢Èí·Ç³£¾µäµÄµ÷ÊÔ¹¤¾ß£¬±¾È˷dz£Ï²»¶¡£²»Öª²»¾õѧÁËMFC£¬»¨Á˲»ÉÙʱ¼äÓëÒø×Ó£¬¸Ð¾õMFCÕæµÄÊDz©´ó¾«É¾ÍÏñÒ»Öַdz£¸ßÉîµÄÎ书£¬¾ÍÏñÌ«¼«£¬ÈëÃÅÄÑ¡£javaÏñÎäµ±¡£Visual C++ÐèÒª±È½ÏÉîºñµÄÄÚ¹¦²ÅÄÜÐÞÁ¶ºÃ£¬²»¹ýjavaѧºÃÁËÒ²²»´í£¬²»¹ÜѧÄĸö£¬×îÖյľ³½ç¶¼ÊǸÕÈáÏà¼Ã¡£Î书Èç´Ë£¬±à³ÌÓïÑÔ¿ª·¢ ......