home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / harbb30g.zip / INCLUDE / init.h < prev    next >
C/C++ Source or Header  |  1999-09-17  |  4KB  |  132 lines

  1. /*
  2.  * $Id: init.h,v 1.27 1999/09/17 11:43:24 vszel Exp $
  3.  */
  4.  
  5. /*
  6.  * Harbour Project source code:
  7.  * Header file for automatic static initialization
  8.  *
  9.  * Copyright 1999 Antonio Linares <alinares@fivetech.com>
  10.  * www - http://www.harbour-project.org
  11.  *
  12.  * This program is free software; you can redistribute it and/or modify
  13.  * it under the terms of the GNU General Public License as published by
  14.  * the Free Software Foundation; either version 2 of the License, or
  15.  * (at your option) any later version, with one exception:
  16.  *
  17.  * The exception is that if you link the Harbour Runtime Library (HRL)
  18.  * and/or the Harbour Virtual Machine (HVM) with other files to produce
  19.  * an executable, this does not by itself cause the resulting executable
  20.  * to be covered by the GNU General Public License. Your use of that
  21.  * executable is in no way restricted on account of linking the HRL
  22.  * and/or HVM code into it.
  23.  *
  24.  * This program is distributed in the hope that it will be useful,
  25.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  27.  * GNU General Public License for more details.
  28.  *
  29.  * You should have received a copy of the GNU General Public License
  30.  * along with this program; if not, write to the Free Software
  31.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
  32.  * their web site at http://www.gnu.org/).
  33.  *
  34.  */
  35.  
  36. #ifndef HB_INIT_H_
  37. #define HB_INIT_H_
  38.  
  39. extern void hb_vmProcessSymbols( PHB_SYMB pSymbols, USHORT uiSymbols ); /* statics symbols initialization */
  40.  
  41. #ifdef HARBOUR_STRICT_ANSI_C
  42.  
  43. #define HB_INIT_SYMBOLS_BEGIN( func ) \
  44.    static HB_SYMB symbols[] = {
  45.  
  46. #define HB_INIT_SYMBOLS_END( func ) }; \
  47.    void func( void ) \
  48.    { \
  49.       hb_vmProcessSymbols( symbols, sizeof( symbols ) / sizeof( HB_SYMB ) ); \
  50.    }
  51.  
  52. #define HB_CALL_ON_STARTUP_BEGIN( func ) func( void ) {
  53. #define HB_CALL_ON_STARTUP_END( func ) }
  54.  
  55. #else /* HARBOUR_STRICT_ANSI_C */
  56.  
  57. #ifdef __GNUC__
  58. #define HB_INIT_SYMBOLS_BEGIN( func ) \
  59.    static HB_SYMB symbols[] = {
  60.  
  61. #define HB_INIT_SYMBOLS_END( func )  }; \
  62.    static void __attribute__ ((constructor)) func( void ) \
  63.    { \
  64.       hb_vmProcessSymbols( symbols, sizeof( symbols ) / sizeof( HB_SYMB ) ); \
  65.    }
  66.  
  67.  
  68. #define HB_CALL_ON_STARTUP_BEGIN( func ) \
  69.    static void __attribute__ ((constructor)) func( void ) {
  70.  
  71. #define HB_CALL_ON_STARTUP_END( func ) }
  72. #endif
  73.  
  74.  
  75. #ifdef __BORLANDC__
  76. #define HB_INIT_SYMBOLS_BEGIN( func ) \
  77.    static HB_SYMB symbols[] = {
  78.  
  79. #define HB_INIT_SYMBOLS_END( func )  }; \
  80.    static void func( void ) \
  81.    { \
  82.       hb_vmProcessSymbols( symbols, sizeof( symbols ) / sizeof( HB_SYMB ) ); \
  83.    }
  84.  
  85. #define HB_CALL_ON_STARTUP_BEGIN( func ) \
  86.    static void func( void ) {
  87.  
  88. #define HB_CALL_ON_STARTUP_END( func ) }
  89. #endif
  90.  
  91. #if (defined(_MSC_VER) || defined(__IBMCPP__) || defined(__MPW__))
  92. #define HB_INIT_SYMBOLS_BEGIN( func ) \
  93.    static HB_SYMB symbols[] = {
  94.  
  95. #define HB_INIT_SYMBOLS_END( func ) }; \
  96.    static int func( void ) \
  97.    { \
  98.       hb_vmProcessSymbols( symbols, sizeof( symbols ) / sizeof( HB_SYMB ) ); \
  99.       return 1; \
  100.    }; \
  101.    static int static_int_##func = func();
  102.  
  103. #define HB_CALL_ON_STARTUP_BEGIN( func ) \
  104.    static int func( void ) {
  105.  
  106. #define HB_CALL_ON_STARTUP_END( func ) return 1; } \
  107.    static int static_int_##func = func();
  108. #endif
  109.  
  110. #ifdef __WATCOMC__
  111. #define HB_INIT_SYMBOLS_BEGIN( func ) \
  112.    static HB_SYMB symbols[] = {
  113.  
  114. #define HB_INIT_SYMBOLS_END( func ) }; \
  115.    static int func( void ) \
  116.    { \
  117.       hb_vmProcessSymbols( symbols, sizeof( symbols ) / sizeof( HB_SYMB ) ); \
  118.       return 1; \
  119.    }; \
  120.    static int static_int_##func = func();
  121.  
  122. #define HB_CALL_ON_STARTUP_BEGIN( func ) \
  123.    static int func( void ) {
  124.  
  125. #define HB_CALL_ON_STARTUP_END( func ) return 1; }; \
  126.    static int static_int_##func = func();
  127. #endif
  128.  
  129. #endif /* HARBOUR_STRICT_ANSI_C */
  130.  
  131. #endif /* HB_INIT_H_ */
  132.