라벨이 cleanup인 게시물 표시

OS/2 codes: How to writes initialization/termination codes with gcc

When programming, one of the most annoying things is to write initialization/termination codes. In case of DLL, OS/2 provides the opportunity for this by _DLL_InitTerm(). However, if it is a static library, OS/2 does not provide any ways for this. Instead, compilers provides its own ways for this. Of course, gcc has its own ways. They are __attribute__((consturctor)) for intialization and __attribute__((destructor)) for termination. Here are the sample code. Colored By Color Scripter ™ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #include  <stdio.h> __attribute__((constructor)) static   void  before(  void  ) {     printf( "constructor : before()\n" ); } __attribute__((destructor)) static   void  after(  void  ) {     printf( "destructor : after()\n" ); } int  main(  void  ) {     printf( "ma...