³ÌÐòÔ±µÄ×ÔÎÒÐÞÑø: ³ÌÐòÔËÐеĻùʯ C/C++ÔËÐпâ
Ò»¸öCÓïÑÔÔËÐпâ´óÖ°üº¬ÁËÈçϹ¦ÄÜ:
1. Æô¶¯ÓëÍ˳ö: °üÀ¨Èë¿Úº¯Êý¼°Èë¿Úº¯ÊýËùÒÀÀµµÄÆäËüº¯ÊýµÈ
2. ±ê×¼º¯Êý: ÓÉCÓïÑÔ±ê×¼¹æ¶¨µÄCÓïÑÔ±ê×¼¿âËùÓµÓеĺ¯ÊýʵÏÖ.
3. I/O: IO¹¦Äܵķâ×°ºÍʵÏÖ
4. ¶Ñ:¶ÑµÄ·â×°ºÍʵÏÖ
5. ÓïÑÔʵÏÖ: ÓïÑÔÖÐһЩÌØÊ⹦ÄܵÄʵÏÖ.
6. µ÷ÊÔ: ʵÏÖµ÷ÊÔ¹¦ÄܵĴúÂë.
ÔÚÕâЩÔËÐпâµÄ×é³É³É·ÖÖÐ, CÓïÑÔ±ê×¼Õ¼¾ÝÁËÖ÷Òª²¢ÇÒ´óÓÐÀ´Í·.
1. ±ä³¤²ÎÊý
º¯ÊýµÄʵÏÖÈçÏÂ:
#define _crt_va_start(ap,v) ( ap = (va_list)_ADDRESSOF(v) + _INTSIZEOF(v) )
//va_startÈ¡µÚÒ»¸ö²ÎÊýµÄµØÖ·, ²¢ÔÚÕ»ÉÏÏòÉÏÒƶ¯Ö¸Õë
#define _crt_va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
//va_argÖ÷ÒªÊÇÏÈÒƶ¯Ö¸Õë,ÔÙÈ¡ÉÏÒ»¸öÖµ.
//×¢Òâ: tÊÇÖ¸Òª´«ÈëµÄÀàÐÍ,ӦΪҪȷ¶¨Òƶ¯µÄÖ¸ÕëµÄÔ¶½ü.
#define _crt_va_end(ap) ( ap = (va_list)0 )
//ʹapÖ¸ÕëΪ0
//Ö÷ÒªÊÇÀûÓÃÕ»µÄÔÀí.
#include <stdio.h>
#include <stdarg.h>
int sum(int a, ...)
{
int v = 0;
va_list ap;
va_start(ap, a);
while(a--)
v += va_arg(ap, int);
va_end(ap);
return v;
}
int main()
{
printf("%d", sum(9, 1,2,3,4,5,6,7,8,9));
return 0;
}
2. ·Ç¾Ö²¿Ìøת
#include <setjmp.h>
jmp_buf b;
void f()
{
longjmp(b, 1);
}
int main()
{
if(setjmp(b))
printf("World!");
else
{
printf("Hello ");
f();
}
return 0;
}
½á¹û: Hello World!
µ±µ÷ÓÃlongjmpʱ,ÔËÐе½setjmp·µ»ØµÄλÖÃ,²¢°ÑsetjmpµÄ·µ»ØÉèÖÃΪ1
¹ØÓÚ²»Í¬°æ±¾CRTµÄÎÊÌâ
1. ΪʲôÓÃVC2008±àÒëµÄ³ÌÐòÎÞ·¨ÔÚ±ðÈ˵ĻúÆ÷ÉÏÔËÐÐ?
ÒòΪVC2008±àÒëµÄ³ÌÐòʹÓÃÁËmanifest»úÖÆ, ÕâЩ³ÌÐò±ØÐëÒÀÀµÓÚÏà¶ÔÓ¦°æ±¾µÄÔËÐпâ.
Ò»¸ö½â¾ö°ì·¨¾ÍÊÇʹÓþ²Ì¬Á´½Ó, ÕâÑù¾Í²»ÐèÒªÒÀÀµÓÚCRTµÄDLL.
ÁíÒ»°ì·¨Êǽ«ÏàÓ¦°æ±¾µÄÔËÐпâÓë³ÌÐòÒ»Æð·¢²¼¸ø×îÖÕÓû§.
2. Èç¹ûÒ»¸ö³ÌÐòÀïÃæµÄ²»Í¬objÎļþ»òdllÎļþʹÓÃÁ˲»Í¬µÄCRT, »á²»»áÓÐÎÊÌâ?
Èç¹ûÖ»ÓÐobjûÓÐdll, ÕâʱÊǾ²Ì¬Á´½Ó, ²»Í¬µÄobjÔÚ±àÒëʱÓõ½Á˲»Í¬°æ±¾µÄ¾²Ì¬CRT. Ò»°ãÊDz»»á³öÏÖÎÊÌâµÄ. ÒòΪĿ±êÎļþ¶Ô¾²Ì¬¿âÒýÓÃÖ»ÊÇÔÚÄ¿±êÎļþµÄ·ûºÅ±íÖб£ÁôÒ»¸ö¼ÇºÅ, ²»½øÐÐÁ´½Ó, ûÓо²Ì¬¿âµÄ°æ±¾ÐÅÏ¢.
µ«ÊÇÈç¹ûº¬Óв»Í¬°æ±¾µÄdllÎļþ, ÔòÓпÉÄܳöÏÖÎÊÌâ.
Ïà¹ØÎĵµ£º
×î½üÔÚ×ö³ÌÐòʱÐèҪʹÓÃÒ»¸öÒѾ±àºÃµÄC³ÌÐòÔ´Îļþ£¨ÓÐÍ·Îļþ£©£¬½«Í·Îļþ¼ÓÈëÒªµ÷ÓõÄÔ´ÎļþÖУ¬µ÷ÓÃÏàÓ¦Cº¯Êý£¬±àÒëʱ³öÏÖÈçÏ´íÎó£º
sss.c(3129) : fatal error C1010: unexpected end of file while looking for precompiled header directive
ÔÚÍøÉϲéÁËÏà¹Ø×ÊÁÏ£¬Ëµ²»ÄÜÔÚCÔ´ÎļþÖаüº¬"stdafx.h"Îļþ£¬
ÖªµÀÐèÒªÒ ......
C/C++ÓïÑÔʵÏÖ¶¯Ì¬Êý×é
CÊý×éµÄСÎÊÌâ
ÕâÀï˵µÄ¶¯Ì¬Êý×éÊÇ¿ÉÒÔ¸ù¾ÝÐèÒª¶¯Ì¬Ôö³¤Õ¼ÓÃÄÚ´æµÄÊý×飬±ÈÈç³ÌÐò³õʼ·ÖÅäÁË100¸öÔªËØ£¬¿ÉÊÇÔËÐÐÁËÒ»¶Îʱ¼äºóÇøÇø100¸ö¿Õ¼ä²»ÄÜÂú×ãÁË£¬ÏÖÔÚÐèÒª400¸ö£¬Ôõô°ìÄØ£»Äǿ϶¨ÐèÒªÔÙ¶îÍâ·ÖÅä300¸ö¡£
CÓïÑÔÓÐrealloc()º¯ÊýÀ´½â¾ö¿Õ¼ä ......
½ñÌìÔÚVS2005µ÷ÊÔÒ»¸öC# C/S³ÌÐò£¬µ±Í¨¹ýRFCÓëSAPÁ¬½Óʱ¼ä¹ý³¤Ê±£¬³öÏÖ´Ë´íÎó£¬ÔÚÍøÉÏÕÒµ½½â¾ö°ì·¨¡£
VS2008ÉϵÄÒ»¸ö³ÌÐò£¬Í¨¹ýOracle.DataAccess.dllÖ´ÐÐdrop user
cascade²Ù×÷£¬ÎÒÔÚsqlplusÖ´Ðд˲Ù×÷´óÔ¼ÐèÒªÒ»·ÖÖÓ×óÓÒʱ¼ä£¬µ±ÎÒÔÚVS2008ÖÐdebugÆô¶¯´Ë³ÌÐòʱ£¬Ò»Ö±½ÓÊÕµ½
“ContextSwitchDeadlock is detected& ......
extern "C"°üº¬Ë«Öغ¬Ò壬ÆäÒ»£º±»ËüÐÞÊεÄÄ¿±êÊÇ“extern”µÄ£»Æä¶þ£º±»ËüÐÞÊεÄÄ¿±êÊÇ“C”µÄ¡£
1£©±»extern “C”ÏÞ¶¨µÄº¯Êý»ò±äÁ¿ÊÇexternÀàÐ͵ģ»
externÊÇC/C++ÓïÑÔÖбíÃ÷º¯ÊýºÍÈ«¾Ö±äÁ¿×÷Ó÷¶Î§£¨¿É¼ûÐÔ£©µÄ¹Ø¼ü×Ö£¬¸Ã¹Ø¼ü×Ö¸æËß±àÒëÆ÷£¬ÆäÉùÃ÷µÄº¯ÊýºÍ±äÁ¿¿ÉÒÔ ......