Çë½Ìc¸ßÊÖ£¬defineµÄÎÊÌâ
¸÷λ´óÏÀ£¬Ð¡µÜÓÐÒ»¸öÎÊÌâÇë½Ì£¬ÈçÏÂ
Õâ¸ö #define stack_push ÊÇÒ»¸öº¯Êý£¬µ÷ÓÃÊÇÕâÑùµÄ
int len;
stack_t *stack;
const char *curpos;
int seglen;
const char *next_slash;
int i;
---------
ÒÔÉÏÊDZäÁ¿µÄ¶¨Òå¡£
if (stack_push(curpos, const char *, stack) < 0 || stack_push(next_slash - curpos + 1, int, stack) < 0)
{
stack_destroy(stack);
return -1;
}
ÖÚ´ó¸ç´ó½ãÃÇ£¬ÎÒµÄÎÊÌâ²»ÊÇÕâ¸öµ÷Ó㬶øÊÇÏÂÃæµÄÕâ¸öºê¶¨ÒåÎÒÓиöµØ·½¿´²»Ã÷°×£¬¾ÍÊÇ||ºóÃæµÄ²¿·Ö £¬ÓÈÆäÊÇ*((type *)(stack)->top)++ = (elem), Õⲿ·Ö£¬ÕæµÄÊÇ¿´²»Ã÷°×£¬Çë¸÷λ¸ßÊÖÖ¸½Ìһϰɡ£Ð»Ð»¡£
ʵ¼ÊÉÏÕâ¸öÊǸö±í´ïʽ£¬µ«ÊÇ(elem), Õâ¸öµØ·½£¬¾Í¿´²»Ã÷°×ÁË£¬ÔõôÌæ»»ºÃÏñ¶¼²»¶Ô¡£¸ßÊÖ°ïÎÒ½âÊÍÒ»ÏÂÕâ¶Î´úÂë°É
#define stack_push(elem, type, stack) \
({ \
(stack)->top + sizeof (type) <= (stack)->base + (stack)->size || \
__stack_expand(stack, sizeof (type)) >= 0 ? \
*((type *)(stack)->top)++ = (elem), (stack)->top - (stack)->base : -1; \
})
/* Never call the following function directly. */
int __stack_expand(stack_t *stack, unsigned int esize);
Æäʵ¾ÍÊǸö?:±í´ïʽ
?ÅжϵÄÌõ¼þÊÇ(stack)->top + sizeof (type) <= (stack)->base + (stack)->size »òÕß
__stack_expand(stack, sizeof (type)) >= 0
Èç¹ûÕâÁ½¸ö±í´ïʽÖÁÉÙÓÐÒ»
Ïà¹ØÎÊ´ð£º
ÔÚ¸ùĿ¼/libÖдæ·ÅÒ»¸ölog.c£¬log.h£¬²¢ÓÃÏÂÃæµÄÓï¾ä£º
gcc -c log.c
ar crv liblog.a log.o
±àÒë³öÒ»¸öliblog.a¾²Ì¬¿â£¬È»ºóÔÚÎļþ¼Ð£º/testfileÖд´½¨Ò»¸ötest.cºÍtestc.c£¬test.cÖÐÒýÓÃÁËtestc.cÖж¨ÒåµÄ·½·¨ ......
´ó¼ÒºÃ£¬ÎÒÊÇÐÂÊÖ£¬¸Õ¿ªÊ¼½Ó´¥C/S½á¹¹µÄ³ÌÐò£¬ÏëҪʵÏÖÒ»¸ö·ÖÒ³¹¦ÄÜ£¬´ó¼ÒÓÐûÓкõãµÄ·ÖÒ³¿Ø¼þ»òÕß³ÌÐòÖ®ÀàµÄ£¬µ±È»Ô´³ÌÐò¸üºÃ£¬·ñÔò˵˵Á÷³ÌÒ²¿ÉÒÔ£¬Ð¡Ãü±°¡£¬ÔÚÏߵȡ£¡£¡£¡£
´ó¼Ò°ï°ï棬лÁË£¡
×Ô¼ºÐ´Ñ½£¡
......
СµÜ×î½üÔÚÁ˽â¹ØÓÚtiny c µÄÎÊÌâ¡£ÔÚlinuxÏÂ×¼±¸°²×°¡£µ«°²×°Íê³ÉºóÅöµ½ÁËһЩÎÊÌ⡣ϣÍû´ó¼ÒÄܹ»°ïæ½â¾ö¡£ÒÔÏÂÊÇ°²×°Íê³ÉºóµÄÖ´Ðв½Öè¡£
[student@localhost ~]$ tcc -v
tcc version 0.9.25
[student@localhos ......
ÎÒˮƽºÜ²Ë£¬ÌáÎʵĹÀ¼ÆÒ²ºÜ¸ãЦ£¬ºÇºÇ£¬¸ßÊÖ¼ûÁ¡£
ÎÒÔÚ´úÂëÀïÃæÌí¼ÓÁËÒ»¸ö.cÎļþA£¬ÀïÃæÓÐÒ»¸öº¯Êýf£¬È»ºóÎÒÔÚÁíÍâÒ»¸ö.cÎļþBÖе÷Óô˺¯Êýf£¬µ«ÊÇ£¬BÎļþÖв¢Ã»Óаüº¬¶Ôº¯ÊýfµÄÉùÃ÷£¬Ò²¾ÍÊÇ˵ûÓаüº¬ÎļþAµÄ.h£ ......