c±àÒëÈ«¹ý³Ì
CÓïÑÔ±àÒëÈ«¹ý³Ì
±àÒëµÄ¸ÅÄ±àÒë³ÌÐò¶ÁÈ¡Ô´³ÌÐò£¨×Ö·ûÁ÷£©£¬¶ÔÖ®½øÐдʷ¨ºÍÓï·¨µÄ·ÖÎö£¬½«¸ß¼¶ÓïÑÔÖ¸Áîת»»Îª¹¦ÄܵÈЧµÄ»ã±à´úÂ룬ÔÙÓÉ»ã±à³ÌÐòת»»Îª»úÆ÷ÓïÑÔ£¬²¢ÇÒ°´ÕÕ²Ù×÷ϵͳ¶Ô¿ÉÖ´ÐÐÎļþ¸ñʽµÄÒªÇóÁ´½ÓÉú³É¿ÉÖ´ÐгÌÐò¡£
±àÒëµÄÍêÕû¹ý³Ì£ºCÔ´³ÌÐò££>Ô¤±àÒë´¦Àí(.c)££>±àÒë¡¢ÓÅ»¯³ÌÐò£¨.s¡¢.asm£©££>»ã±à³ÌÐò(.obj¡¢.o¡¢.a¡¢.ko)££>Á´½Ó³ÌÐò£¨.exe¡¢.elf¡¢.axfµÈ£©
1. ±àÒëÔ¤´¦Àí
¶ÁÈ¡cÔ´³ÌÐò£¬¶ÔÆäÖеÄαָÁÒÔ#¿ªÍ·µÄÖ¸ÁºÍÌØÊâ·ûºÅ½øÐд¦Àí
αָÁîÖ÷Òª°üÀ¨ÒÔÏÂËĸö·½Ã棺
£¨1£©ºê¶¨ÒåÖ¸ÁÈç#define Name TokenString£¬#undefµÈ¡£
¶ÔÓÚÇ°Ò»¸öαָÁԤ±àÒëËùÒª×öµÄÊǽ«³ÌÐòÖеÄËùÓÐNameÓÃTokenStringÌæ»»£¬µ«×÷Ϊ×Ö·û´®³£Á¿µÄ NameÔò²»±»Ìæ»»¡£¶ÔÓÚºóÕߣ¬Ôò½«È¡Ïû¶Ôij¸öºêµÄ¶¨Ò壬ʹÒÔºó¸Ã´®µÄ³öÏÖ²»ÔÙ±»Ìæ»»¡£
£¨2£©Ìõ¼þ±àÒëÖ¸ÁÈç#ifdef£¬#ifndef£¬#else£¬#elif£¬#endifµÈ¡£
ÕâЩαָÁîµÄÒýÈëʹµÃ³ÌÐòÔ±¿ÉÒÔͨ¹ý¶¨Ò岻ͬµÄºêÀ´¾ö¶¨±àÒë³ÌÐò¶ÔÄÄЩ´úÂë½øÐд¦Àí¡£Ô¤±àÒë³ÌÐò½«¸ù¾ÝÓйصÄÎļþ£¬½«ÄÇЩ²»±ØÒªµÄ´úÂë¹ýÂ˵ô
£¨3£© Í·Îļþ°üº¬Ö¸ÁÈç#include "FileName"»òÕß#include <FileName>µÈ¡£
ÔÚÍ·ÎļþÖÐÒ»°ãÓÃαָÁî#define¶¨ÒåÁË´óÁ¿µÄºê£¨×î³£¼ûµÄÊÇ×Ö·û³£Á¿£©£¬Í¬Ê±°üº¬Óи÷ÖÖÍⲿ·ûºÅµÄÉùÃ÷¡£
²ÉÓÃÍ·ÎļþµÄÄ¿µÄÖ÷ÒªÊÇΪÁËʹijЩ¶¨Òå¿ÉÒÔ¹©¶à¸ö²»Í¬µÄCÔ´³ÌÐòʹÓá£ÒòΪÔÚÐèÒªÓõ½ÕâЩ¶¨ÒåµÄCÔ´³ÌÐòÖУ¬Ö»Ðè¼ÓÉÏÒ»Ìõ#includeÓï¾ä¼´¿É£¬¶ø²»±ØÔÙÔÚ´ËÎļþÖн«ÕâЩ¶¨ÒåÖظ´Ò»±é¡£Ô¤±àÒë³ÌÐò½«°ÑÍ·ÎļþÖеĶ¨Òåͳͳ¶¼¼ÓÈëµ½ËüËù²úÉúµÄÊä³öÎļþÖУ¬ÒÔ¹©±àÒë³ÌÐò¶ÔÖ®½øÐд¦Àí¡£
°üº¬µ½cÔ´³ÌÐòÖеÄÍ·Îļþ¿ÉÒÔÊÇϵͳÌṩµÄ£¬ÕâЩͷÎļþÒ»°ã±»·ÅÔÚ/usr/includeĿ¼Ï¡£ÔÚ³ÌÐòÖÐ#includeËüÃÇҪʹÓüâÀ¨ºÅ£¨< >£©¡£ÁíÍ⿪·¢ÈËÔ±Ò²¿ÉÒÔ¶¨Òå×Ô¼ºµÄÍ·Îļþ£¬ÕâЩÎļþÒ»°ãÓëcÔ´³ÌÐò·ÅÔÚͬһĿ¼Ï£¬´ËʱÔÚ#includeÖÐÒªÓÃË«ÒýºÅ£¨""£©¡£
£¨4£©ÌØÊâ·ûºÅ£¬Ô¤±àÒë³ÌÐò¿ÉÒÔʶ±ðһЩÌØÊâµÄ·ûºÅ¡£
ÀýÈçÔÚÔ´³ÌÐòÖгöÏÖµÄLINE±êʶ½«±»½âÊÍΪµ±Ç°Ðкţ¨Ê®½øÖÆÊý£©£¬FILEÔò±»½âÊÍΪµ±Ç°±»±àÒëµÄCÔ´³ÌÐòµÄÃû³Æ¡£Ô¤±àÒë³ÌÐò¶ÔÓÚÔÚÔ´³ÌÐòÖгöÏÖµÄÕâЩ´®½«ÓúÏÊʵÄÖµ½øÐÐÌæ»»¡£
Ô¤±àÒë³ÌÐòËùÍê³ÉµÄ»ù±¾ÉÏÊǶÔÔ´³ÌÐòµÄ“Ìæ´ú”¹¤×÷¡£¾¹ý´ËÖÖÌæ´ú£¬Éú³ÉÒ»¸öÃ
Ïà¹ØÎĵµ£º
VB
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
MSComm1.CommPort = i1
MSComm1.PortOpen = True
MSComm1.InputMode = comInputModeBinary
MSComm1.InBufferCount = 0
& ......
ÕâƪÎÄÕÂÊÇʹÓÃSQLite C/C++½Ó¿ÚµÄÒ»¸ö¸ÅÒª½éÉܺÍÈëÃÅÖ¸ÄÏ¡£
ÓÉÓÚÔçÆÚµÄSQLiteÖ»Ö§³Ö5¸öC/C++½Ó¿Ú£¬Òò¶ø·Ç³£ÈÝÒ×ѧϰºÍʹÓ㬵«ÊÇËæ×ÅSQLite¹¦ÄܵÄÔöÇ¿£¬ÐµÄC/C++½Ó¿Ú²»¶ÏµÄÔö¼Ó½øÀ´£¬µ½ÏÖÔÚÓг¬¹ý150¸ö²»Í¬µÄAPI½Ó¿Ú¡£ÕâÍùÍùʹ³õѧÕßÍû¶øÈ´²½¡£ÐÒÔ˵ÄÊÇ£¬´ó¶àÊýSQLiteÖеÄC/C++½Ó¿ÚÊÇרÓõģ¬Òò¶øºÜÉÙ±»Ê¹Óõ½¡£¾¡¹ÜÓÐÕâ ......
Delphi Óë C/C++ Êý¾ÝÀàÐͶÔÕÕ±í
DelphiÊý¾ÝÀàÐÍC/C++
ShorInt
8λÓзûºÅÕûÊý
char
Byte
8λÎÞ·ûºÅÕûÊý
BYTE,unsigned short
SmallInt
16λÓзûºÅÕûÊý
short
Word
16λÎÞ·ûºÅÕûÊý
unsigned short
Integer,LongInt
32λÓзûºÅÕûÊý
int,long
Cardinal,LongWord/DWORD
32λÎÞ·ûºÅÕûÊý
unsigned long
Int6 ......
#include <stdio.h>
struct Foo1
{
char a;
int b;
char c;
int d;
};
#pragma pack (2)
struct Foo2
{
char a;
int b;
char c;
int d; ......