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

C/C++ÖеÄÄÚ´æ²¹Æë»úÖÆ

      ÔÚCÓïÑÔÖУ¬½á¹¹ÊÇÒ»ÖÖ¸´ºÏÊý¾ÝÀàÐÍ£¬Æä¹¹³ÉÔªËؼȿÉÒÔÊÇ»ù±¾Êý¾ÝÀàÐÍ£¨Èçint¡¢long¡¢floatµÈ£©µÄ±äÁ¿£¬Ò²¿ÉÒÔÊÇһЩ¸´ºÏÊý¾ÝÀàÐÍ£¨ÈçÊý×é¡¢½á¹¹¡¢ÁªºÏµÈ£©µÄÊý¾Ýµ¥Ôª¡£ÔڽṹÖУ¬±àÒëÆ÷Ϊ½á¹¹µÄÿ¸ö³ÉÔ±°´Æä×ÔÈ»¶Ô½ç£¨alignment£©Ìõ¼þ·ÖÅä¿Õ¼ä¡£¸÷¸ö³ÉÔ±°´ÕÕËüÃDZ»ÉùÃ÷µÄ˳ÐòÔÚÄÚ´æÖÐ˳Ðò´æ´¢£¬µÚÒ»¸ö³ÉÔ±µÄµØÖ·ºÍÕû¸ö½á¹¹µÄµØÖ·Ïàͬ¡£ÀýÈ磬ÏÂÃæµÄ½á¹¹¸÷³ÉÔ±¿Õ¼ä·ÖÅäÇé¿ö£º
struct test
{
     char x1;
     short x2;
     float x3;
     char x4;
};
½á¹¹µÄµÚÒ»¸ö³ÉÔ±x1ΪcharÀàÐÍ£¬Æä×ÔÈ»¶Ô½çΪ1£¬ÆäÆ«ÒƵØַΪ0£¬Õ¼¾ÝÁ˵Ú1¸ö×Ö½Ú¡£µÚ¶þ¸ö³ÉÔ±x2ΪshortÀàÐÍ£¬Æä×ÔÈ»¶Ô½çΪ2£¬ÆðʼµØÖ·±ØÐë2×ֽڶԽ磬Òò´Ë£¬±àÒëÆ÷ÔÚx2ºÍx1Ö®¼äÌî³äÁËÒ»¸ö¿Õ×Ö½Ú¡£½á¹¹µÄµÚÈý¸ö³ÉÔ±x3ºÍµÚËĸö³ÉÔ±x4Ç¡ºÃÂäÔÚÆä×ÔÈ»¶Ô½çµØÖ·ÉÏ£¬ÔÚËüÃÇÇ°Ãæ²»ÐèÒª¶îÍâµÄÌî³ä×Ö½Ú¡£ÔÚtest½á¹¹ÖУ¬³ÉÔ±x3ÒªÇó4×ֽڶԽ磬ÊǸýṹËùÓгÉÔ±ÖÐÒªÇóµÄ×î´ó¶Ô½çµ¥Ôª£¬Òò¶øtest½á¹¹µÄ×ÔÈ»¶Ô½çÌõ¼þΪ4×Ö½Ú£¬±àÒëÆ÷ÔÚ³ÉÔ±x4ºóÃæÌî³äÁË3¸ö¿Õ×Ö½Ú¡£Õû¸ö½á¹¹ËùÕ¼¾Ý¿Õ¼äΪ12×Ö½Ú¡£
      ¸ü¸ÄC±àÒëÆ÷µÄȱʡ×Ö½Ú¶ÔÆ뷽ʽ
ÔÚȱʡÇé¿öÏ£¬C±àÒëÆ÷Ϊÿһ¸ö±äÁ¿»òÊÇÊý¾Ýµ¥Ôª°´Æä×ÔÈ»¶Ô½çÌõ¼þ·ÖÅä¿Õ¼ä¡£Ò»°ãµØ£¬¿ÉÒÔͨ¹ýÏÂÃæµÄ·½·¨À´¸Ä±äȱʡµÄ¶Ô½çÌõ¼þ£º
     · ʹÓÃαָÁî#pragma pack (n)£¬C±àÒëÆ÷½«°´ÕÕn¸ö×Ö½Ú¶ÔÆë¡£
     · ʹÓÃαָÁî#pragma pack ()£¬È¡Ïû×Ô¶¨Òå×Ö½Ú¶ÔÆ뷽ʽ¡£
ÁíÍ⣬»¹ÓÐÈçϵÄÒ»ÖÖ·½Ê½£º
     · __attribute((aligned (n)))£¬ÈÃËù×÷ÓõĽṹ³ÉÔ±¶ÔÆëÔÚn×Ö½Ú×ÔÈ»±ß½çÉÏ¡£Èç¹û½á¹¹ÖÐÓгÉÔ±µÄ³¤¶È´óÓÚn£¬Ôò°´ÕÕ×î´ó³ÉÔ±µÄ³¤¶ÈÀ´¶ÔÆë¡£
     · __attribute__ ((packed))£¬È¡Ïû½á¹¹ÔÚ±àÒë¹ý³ÌÖеÄÓÅ»¯¶ÔÆ룬°´ÕÕʵ¼ÊÕ¼ÓÃ×Ö½ÚÊý½øÐжÔÆë¡£
ÒÔÉϵÄn = 1, 2, 4, 8, 16... µÚÒ»ÖÖ·½Ê½½ÏΪ³£¼û¡£
http://blog.csdn.net/wenddy112/articles/300583.aspx
Ó¦ÓÃʵÀý
¡¡¡¡ÔÚÍøÂçЭÒé±à³ÌÖУ¬¾­³£»á´¦Àí²»Í¬Ð­ÒéµÄÊý¾Ý±¨ÎÄ¡£Ò»ÖÖ·½·¨ÊÇͨ¹ýÖ¸ÕëÆ«ÒƵķ½·¨À´µÃµ½¸÷ÖÖÐÅÏ¢£¬µ«ÕâÑù×ö²»½ö±à³Ì¸´ÔÓ£¬¶øÇÒÒ»µ©Ð­ÒéÓб仯£¬³ÌÐòÐÞ¸ÄÆðÀ´Ò²±È½ÏÂé·³¡£ÔÚÁ˽âÁ˱àÒëÆ÷¶Ô½á¹¹¿Õ¼äµÄ·ÖÅäÔ­ÔòÖ®ºó£¬ÎÒÃÇÍêÈ«¿ÉÒÔÀûÓÃÕâÒ»ÌØÐÔ¶


Ïà¹ØÎĵµ£º

Linux»·¾³MySQLµÄC±à³ÌÆð²½

Ê×ÏÈ°²×°±ØÐèµÄ¿ª·¢
°ü
sudo apt-get install gcc g++ libgcc1 libg++ make gdb
°²×°MYSQLµÄCÓïÑÔ¿ª·¢°ü
sudo apt-get install libmysql++-dev libmysql++2c2a libmysqlclient15-dev libmysqlclient15off
°ÑlibÎļþ¿½±´µ½¹«ÓÃ
sudo cp /usr/lib/mysql/* /usr/lib/
½¨Á¢Ò»¸öÐÂÎļþtest.cpp
vim test.cpp
ÊäÈëÄÚÈÝ
......

Python±Ê¼Ç£¨¶þ£©——pythonµ÷ÓÃC/C++Ä£¿é

ǰһƪ½²Á˼òµ¥µÄC/C++µ÷ÓÃPython½Å±¾Ä£¿é£¨.py£©¡£¼ÈÈ»ÊÇÓÃÓÚÖî¶àÓÎÏ·³ÌÐòµÄ½Å±¾ÓïÑÔ£¬Äǿ϶¨ÊÇȱ²»ÁË»¥µ÷£¨ÀñÉÐÍùÀ´£©¡£Òò´Ë£¬±¾Æª½²Ò»¸ö¼òµ¥µÄpythonµ÷ÓÃC/C++дµÄDLLÄ£¿é£¬¶ÔPython½øÐй¦ÄÜÀ©Õ¹¡£ÕâÀïдһ¸ö¼òµ¥µÄÀý×Ó£¬Ö÷Òª¾ÍΪÁËÁ˽âÏÂÕâôÓÃPythonÀ´µ÷ÓÃC/C++дµÄDLL¿â¡£ºÃÁË£¬ÇÐÈëÕýÌ⣺
 Ê×ÏÈ£¬ÎÒÊÇÓÃVS2003 ......

extern "C"Ïê½â

       C++ÓïÑԵĴ´½¨³õÖÔÊÇ“a better
C”£¬µ«ÊÇÕâ²¢²»Òâζ×ÅC++ÖÐÀàËÆCÓïÑÔµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýËù²ÉÓõıàÒëºÍÁ¬½Ó·½Ê½ÓëCÓïÑÔÍêÈ«Ïàͬ¡£×÷ΪһÖÖÓûÓëC¼æÈݵÄÓïÑÔ£¬C++±£ÁôÁËÒ»²¿·Ö¹ý³Ì
ʽÓïÑÔµÄÌص㣨±»ÊÀÈ˳ÆΪ“²»³¹µ×µØÃæÏò¶ÔÏ󔣩£¬Òò¶øËü¿ÉÒÔ¶¨Òå²»ÊôÓÚÈκÎÀàµÄ ......

smartgwt (C)

   SmartGWTÊÇÒ»¸öÀûÓÃGWT·â×°SmartClientµÄ¿ªÔ´ÏîÄ¿¡£ÀàËÆÓÚGWT-Ext¡£SmartClientÊÇÒ»¸öÆóÒµ¼¶µÄajax¿ò¼Ü£¬°üÀ¨·Ç³£³öÉ«µÄUI¿â¡¢¹¤¾ß¿âºÍ¿Í»§¶Ë·þÎñ¶ËÊý¾Ý°ó¶¨µÈ¹¦ÄÜ¡££¨ÒýÓã©
  UI¿â£ººÜ¶à¿ò¼ÜµÄUI¿âºÜ³öÉ«£¬¿¼ÂǵĺÜÍêÉÆ£¬ä¯ÀÀÆ÷¼æÈÝÐÔÒ²ºÜºÃ£¬µ«ÍùÍùÖ»ÊÇǰ̨µÄ£¬µ±ÄãÏëÉîÈë×öµãÓ¦ÓÃʱ£¬¾Í»á·¢Ïֺͺǫ́ ......

ADC0809 C³ÌÐò

 #include<reg52.h>
#include<intrins.h>
#define uint  unsigned int
#define uchar unsigned char
uint date;
uchar mm=0,n=0;
uint k1,k2,k3,k4,k5,k6;
uchar code b[]={
    0x3f,0x06,0x5b,0x4f,0x66,   //0,1,2,3,4,
    0x6d,0x7d,0x07,0x7 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ