ÈçºÎʹÓÃattributeÊôÐÔ£¿
ÎÒÔںü¸±¾ÊéÖп´µ½ÓÐʹÓÃÊôÐԹؼü×Ö__attribute__µÄ´úÂ룬×Ô¼ºÐ´Á˸öÒ²£¬¿ÉϧÔõôҲ²»ÄÜͨ¹ý±àÒ룬˵ÎÞ·¨Ê¶±ð£¬±»ºöÂÔ£¬ÊDz»ÊÇÒªÔÚ±àÒëµÄʱºò¼ÓÑ¡Ïî°¡£¬ÓÐÖªµÀµÄÅóÓѰï¸öæ°¡£¬Ð»Ð»ÁË£¡ one example:[code][color=blue]-(user@host:tty)-(syntax)-[3768 0] $ [/color]cat attribute.constructor.c:[a ~%m&B-S2e'Dn%s
/*
* Author: <dearvoid AT 263 DOT net>
*
* $Date: 2006-03-13 09:50:30 +0800 (Mon, 13 Mar 2006) $DW&JO$|@
* $HeadURL: svn://jwang/repos/trunk/void/c/syntax/attribute.constructor.c $(JC2[)s+xY,wz X+q7J
* $Revision: 34 $
*/Z+p,}:N} DstYf
H5cfn.c*LpC B7l+N%b
#include <stdio.h>x*~*zp*X2t!_dZ
void start_up(void) __attribute__(( constructor ));B4w\JS7{'n!q
void clean_up(void) __attribute__(( destructor ));
B*E5Y;MR8iV3M
void start_up(void)6~.N,Fg!`d
{c3OT#`"OO8k%^ z
printf("Now in constructor\n");?;ceA*s#pl
}
void clean_up(void)
{
printf("Now in destructor\n");
};z5n u&Y(i#m