C runtime libraryµÄÔËÐÐÔÀí
1)ÔËÐÐʱ¿â¾ÍÊÇ C run-time library£¬ÊÇ C ¶ø·Ç C++ ÓïÑÔÊÀ½çµÄ¸ÅÄî:È¡Õâ¸öÃû×Ö¾ÍÊÇÒòΪÄãµÄ C ³ÌÐòÔËÐÐʱÐèÒªÕâЩ¿âÖеĺ¯Êý.
2)C ÓïÑÔÊÇËùνµÄ“СÄں˔ÓïÑÔ£¬¾ÍÆäÓïÑÔ±¾ÉíÀ´ËµºÜС£¨²»¶àµÄ¹Ø¼ü×Ö£¬³ÌÐòÁ÷³Ì¿ØÖÆ£¬Êý¾ÝÀàÐ͵ȣ©£»ËùÒÔ£¬C ÓïÑÔÄں˿ª·¢³öÀ´Ö®ºó£¬Dennis Ritchie ºÍ Brian Kernighan ¾ÍÓà C ±¾ÉíÖØдÁË 90% ÒÔÉ쵀 UNIX ϵͳº¯Êý£¬²¢ÇÒ°ÑÆäÖÐ×î³£ÓõIJ¿·Ö¶ÀÁ¢³öÀ´£¬ÐγÉÍ·ÎļþºÍ¶ÔÓ¦µÄ LIBRARY£¬C run-time library ¾ÍÊÇÕâÑùÐγɵġ£
3)Ëæºó£¬Ëæ×Å C ÓïÑÔµÄÁ÷ÐУ¬¸÷¸ö C ±àÒëÆ÷µÄÉú²úÉÌ/¸öÌå/ÍÅÌ嶼×ñÑÀϵĴ«Í³£¬ÔÚ²»Í¬Æ½Ì¨É϶¼ÓÐÏà¶ÔÓ¦µÄ Standard Library£¬µ«´ó²¿·ÖʵÏÖ¶¼ÊÇÓë¸÷¸öƽ̨Óйصġ£ÓÉÓÚ¸÷¸ö C ±àÒëÆ÷¶Ô C µÄÖ§³ÖºÍÀí½âÓкܶà·ÖÆçºÍ΢ÃîµÄ²î±ð£¬ËùÒÔ¾ÍÓÐÁË ANSI C£»ANSI C £¨Ö÷¹ÛÒâͼÉÏ£©ÏêϸµÄ¹æ¶¨ÁË C ÓïÑÔ¸÷¸öÒªËصľßÌ庬ÒåºÍ±àÒëÆ÷ʵÏÖÒªÇó£¬Òý½øÁËеĺ¯ÊýÉùÃ÷·½Ê½£¬Í¬Ê±¶©Á¢ÁË Standard Library µÄ±ê×¼ÐÎʽ¡£ËùÒÔCÔËÐÐʱ¿âÓɱàÒëÆ÷Éú²úÉÌÌṩ¡£ÖÁÓÚÓÉÆäËû³§ÉÌ/¸öÈË/ÍÅÌåÌṩµÄÍ·ÎļþºÍ¿âº¯Êý£¬Ó¦µ±³ÆΪµÚÈý·½ C ÔËÐп⣨Third party C run-time libraries£©¡£
4)C run-time libraryÀïÃ溬Óгõʼ»¯´úÂ룬»¹ÓдíÎó´¦Àí´úÂë(ÀýÈçdivide by zero´¦Àí)¡£ÄãдµÄ³ÌÐò¿ÉÒÔûÓÐmath¿â£¬³ÌÐòÕÕÑùÔËÐУ¬Ö»ÊDz»ÄÜ´¦Àí¸´ÔÓµÄÊýѧÔËË㣬²»¹ýÈç¹ûûÓÐÁËC run-time¿â£¬main()¾Í²»»á±»µ÷Óã¬exit()Ò²²»Äܱ»ÏìÓ¦¡£ÒòΪC run-time library°üº¬ÁËC³ÌÐòÔËÐеÄ×î»ù±¾ºÍ×î³£Óõĺ¯Êý¡£
5)µ½ÁË C++ ÊÀ½çÀÓÐÁíÍâÒ»¸ö¸ÅÄî:Standard C++ Library,Ëü°üÀ¨ÁËÉÏÃæËù˵µÄ C run-time library ºÍ STL¡£°üº¬ C run-time library µÄÔÒòºÜÃ÷ÏÔ£¬C++ ÊÇ C µÄ³¬¼¯£¬Ã»ÓÐÀíÓÉÔÙÖØÐÂÀ´Ò»¸ö C++ run-time library. VCÕë¶ÔC++ ¼ÓÈëµÄStandard C++ LibraryÖ÷Òª°üÀ¨£ºLIBCP.LIB, LIBCPMT.LIBºÍ MSVCPRT.LIB
6)Windows»·¾³Ï£¬VCÌṩµÄ C run-time libraryÓÖ·ÖΪ¶¯Ì¬ÔËÐÐʱ¿âºÍ¾²Ì¬ÔËÐÐʱ¿â¡£
¶¯Ì¬ÔËÐÐʱ¿âÖ÷ÒªÊÇDLL¿âÎļþmsvcrt.dll(or MSVCRTD.DLL for debug build),¶ÔÓ¦µÄImport libraryÎļþÊÇMSVCRT.LIB(MSVCRTD.LIB for debug build)
¾²Ì¬ÔËÐÐʱ¿â(release°æ)¶ÔÓ¦µÄÖ÷ÒªÎļþÊÇ£º
LIBC.LIB (Single thread static library, retail version)
LIBCMT.LIB (Multithread static library, retail version)
msvcrt.dllÌṩ¼¸Ç§¸öCº¯Êý£¬¼´Ê¹ÊÇÏñprintfÕâôµÍ¼¶µÄº¯Êý¶¼ÔÚmsvcrt.dllÀï¡£ÆäʵÄãµÄ³ÌÐòÔËÐÐʱ£¬ºÜ´óÒ»²¿·Öʱ¼äʱÔÚÕâЩÔËÐпâ
Ïà¹ØÎĵµ£º
Ô´Â룺
# include <stdio.h>
/* ºê¶¨Òå */
# define MAX 100
# define LEN 80
/* Ò»¸ö·Ç³£¼òµ¥µÄÎı¾±à¼Æ÷ */
int main()
{
char text[MAX][LEN]; // ¶¨Òå×Ö·ûÐÍÊý×é
register int t, i, j; /* ¶¨ÒåÈý¸ö¼Ä´æÆ÷±äÁ¿ */
  ......
ÒÔΪÒѾÕÆÎÕÌõ¼þ±àÒ룬Ԥ±àÒëµÄÒªÁìÁË£¬½á¹û»¹ÊÇ´æÔںܶàÒÅ©µÄµØ·½£¬ËùÒÔ¹æÕûһϣº
Ìõ¼þ±àÒ룺
1
#ifdef _XXXX
...³ÌÐò¶Î1...
#else
...³ÌÐò¶Î2...
#endif
Õâ±íÃ÷Èç¹û±êʶ·û_XXXXÒѱ»#defineÃüÁÒå¹ýÔò¶Ô³ÌÐò¶Î1½øÐбàÒ룻·ñÔò¶Ô³ÌÐò¶Î2½øÐбàÒë¡£
2
#ifndef _XXXX
...³ÌÐò¶Î1...
#else
...³ÌÐ ......
cÓëc++ staticº¯ÊýµÄÇø±ð
c
Óëc++ static
º¯ÊýµÄÇø±ð
static
¹Ø¼ü×ÖÊÇ
C, C++
Öж¼´æÔڵĹؼü×Ö
,
ËüÖ÷ÒªÓÐÈýÖÖʹÓ÷½Ê½
,
ÆäÖÐÇ°Á½ÖÖÖ»Ö¸ÔÚ
C
ÓïÑÔÖÐʹÓÃ
,
µÚÈýÖÖÔÚ
C++
ÖÐʹÓÃ
(C,C++
ÖоßÌåϸ΢²Ù×÷²»¾¡Ïàͬ
,
±¾ÎÄÒÔ
C++
Ϊ׼
).
(1)
¾Ö²¿¾²Ì¬±äÁ¿
(2)
Íⲿ¾²Ì ......
ÖÚ¶àC++Êé¼®¶¼ÖÒ¸æÎÒÃÇCÓïÑÔºêÊÇÍò¶ñÖ®Ê×£¬µ«ÊÂÇé×ܲ»ÈçÎÒÃÇÏëÏóµÄÄÇô»µ£¬¾ÍÈçͬgotoÒ»Ñù¡£ºêÓÐ
Ò»¸öºÜ´óµÄ×÷Ó㬾ÍÊÇ×Ô¶¯ÎªÎÒÃDzúÉú´úÂë¡£Èç¹û˵ģ°å¿ÉÒÔΪÎÒÃDzúÉú¸÷ÖÖÐͱðµÄ´úÂë(ÐͱðÌæ»»)£¬
ÄÇôºêÆäʵ¿ÉÒÔΪÎÒÃÇÔÚ·ûºÅÉϲúÉúеĴúÂë(¼´·ûºÅÌæ»»¡¢Ôö¼Ó)¡£
¹ØÓÚºêµÄһЩÓï·¨ÎÊÌ⣬¿ÉÒÔÔÚgoogleÉÏÕÒµ½¡£ÏàÐÅÎÒ£¬Äã¶Ô ......
ÒýÑÔ
¡¡¡¡Ö¸ÕëÊÇC/C++ÓïÑÔµÄÌØÉ«£¬¶øÊý×éÃûÓëÖ¸ÕëÓÐÌ«¶àµÄÏàËÆ£¬ÉõÖÁºÜ¶àʱºò£¬Êý×éÃû¿ÉÒÔ×÷ΪָÕëʹÓá£ÓÚÊǺõ£¬ºÜ¶à³ÌÐòÉè¼ÆÕ߾ͱ»¸ãºýÍ¿ÁË¡£¶øÐí¶àµÄ´óѧÀÏʦ£¬ËûÃÇÔÚCÓïÑԵĽÌѧ¹ý³ÌÖÐÒ²´íÎóµÃ¸øѧÉú½²½â£º"Êý×éÃû¾ÍÊÇÖ¸Õë"¡£ºÜÐÒÔË£¬ÎҵĴóѧÀÏʦ¾ÍÊÇÆäÖÐÖ®Ò»¡£Ê±ÖÁ½ñÈÕ£¬ÎÒÈÕ¸´Ò»ÈյؽøÐÐ×ÅC/C++ÏîÄ¿µÄ¿ª·¢£¬¶ ......