00001 /* src/Inventor/Gtk/SoGtkBasic.h. Generated automatically by configure. */ 00002 /************************************************************************** 00003 * 00004 * This file is part of the Coin GUI binding libraries. 00005 * Copyright (C) 2000 by Systems in Motion. All rights reserved. 00006 * 00007 * The libraries this file is part of is free software; you can 00008 * redistribute them and/or modify them under the terms of the GNU 00009 * Lesser General Public License version 2.1 as published by the 00010 * Free Software Foundation. See the file LICENSE.LGPL at the root 00011 * directory of the distribution for all the details. 00012 * 00013 * If you want to use the Coin GUI binding libraries for applications 00014 * not compatible with the LGPL, contact SIM about acquiring a 00015 * Professional Edition License. 00016 * 00017 * Systems in Motion, Prof Brochs gate 6, N-7030 Trondheim, NORWAY 00018 * http://www.sim.no/ support@sim.no Voice: +47 22114160 Fax: +47 22207097 00019 * 00020 **************************************************************************/ 00021 00022 // Generated automatically from SoGuiBasic.h.in by configure. 00023 // $Id: SoGuiBasic.h.in,v 1.23 2002/01/26 19:11:24 larsa Exp $ 00024 00025 #ifndef SOGTK_BASIC_H 00026 #define SOGTK_BASIC_H 00027 00028 // ************************************************************************* 00029 00030 /* For the Doxygen tool. */ 00031 /* FIXME: these Doxygen "tags" should be moved to an internal 00032 headerfile. 20010810 mortene. */ 00033 00042 // ************************************************************************* 00043 00044 /* Some useful inline template functions (instead of macros): 00045 * SoGtkMin(Val1, Val2) - returns minimum value 00046 * SoGtkMax(Val1, Val2) - returns maximum value 00047 * SoGtkClamp(Val, Min, Max) - returns clamped value 00048 * SoGtkSwap(Val1, Val2) - swaps the two values (no return value) 00049 * 00050 * FIXME: write Doxygen doc for these methods. 20010810 mortene. 00051 */ 00052 00053 template <class Type> 00054 inline Type SoGtkAbs(Type Val) { 00055 return (Val < 0) ? -Val : Val; 00056 } 00057 00058 template <class Type> 00059 inline Type SoGtkMin(Type a, Type b) { 00060 return (b < a) ? b : a; 00061 } 00062 00063 template <class Type> 00064 inline Type SoGtkMax(Type a, Type b) { 00065 return (b > a) ? b : a; 00066 } 00067 00068 template <class Type> 00069 inline Type SoGtkClamp(Type val, Type min, Type max) { 00070 return SoGtkMax(min, SoGtkMin(max, val)); 00071 } 00072 00073 template <class Type> 00074 inline void SoGtkSwap(Type & a, Type & b) { 00075 Type t = a; a = b; b = t; 00076 } 00077 00078 // ************************************************************************* 00079 00080 #define __COIN_SOGTK__ 00081 00082 #if ! defined(SOGTK_MAJOR_VERSION) 00083 #define SOGTK_MAJOR_VERSION 0 00084 #endif /* ! SOGTK_MAJOR_VERSION */ 00085 #if ! defined(SOGTK_MINOR_VERSION) 00086 #define SOGTK_MINOR_VERSION 9 00087 #endif /* ! SOGTK_MINOR_VERSION */ 00088 #if ! defined(SOGTK_MICRO_VERSION) 00089 #define SOGTK_MICRO_VERSION 99 00090 #endif /* ! SOGTK_MICRO_VERSION */ 00091 #if ! defined(SOGTK_VERSION) 00092 #define SOGTK_VERSION "0.9.99" 00093 #endif /* ! SOGTK_VERSION */ 00094 00095 // ************************************************************************* 00096 00097 /* Precaution to avoid an error easily made by the application programmer. */ 00098 #ifdef SOGTK_DLL_API 00099 # error Leave the internal SOGTK_DLL_API define alone. 00100 #endif /* SOGTK_DLL_API */ 00101 00102 /* 00103 On MSWindows platforms, one of these defines must always be set when 00104 building application programs: 00105 00106 - "SOGTK_DLL", when the application programmer is using the 00107 library in the form of a dynamic link library (DLL) 00108 00109 - "SOGTK_NOT_DLL", when the application programmer is using the 00110 library in the form of a static object library (LIB) 00111 00112 Note that either SOGTK_DLL or SOGTK_NOT_DLL _must_ be defined by 00113 the application programmer on MSWindows platforms, or else the 00114 #error statement will hit. Set up one or the other of these two 00115 defines in your compiler environment according to how the library 00116 was built -- as a DLL (use "SOGTK_DLL") or as a LIB (use 00117 "SOGTK_NOT_DLL"). 00118 00119 (Setting up defines for the compiler is typically done by either 00120 adding something like "/DSOGTK_DLL" to the compiler's argument 00121 line (for command-line build processes), or by adding the define to 00122 the list of preprocessor symbols in your IDE GUI (in the MSVC IDE, 00123 this is done from the "Project"->"Settings" menu, choose the "C/C++" 00124 tab, then "Preprocessor" from the dropdown box and add the 00125 appropriate define)). 00126 00127 It is extremely important that the application programmer uses the 00128 correct define, as using "SOGTK_NOT_DLL" when "SOGTK_DLL" is 00129 correct is likely to cause mysterious crashes. 00130 */ 00131 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) 00132 # ifdef SOGTK_INTERNAL 00133 # ifdef SOGTK_MAKE_DLL 00134 # define SOGTK_DLL_API __declspec(dllexport) 00135 # endif /* SOGTK_MAKE_DLL */ 00136 # else /* !SOGTK_INTERNAL */ 00137 # ifdef SOGTK_DLL 00138 # define SOGTK_DLL_API __declspec(dllimport) 00139 # else /* !SOGTK_DLL */ 00140 # ifndef SOGTK_NOT_DLL 00141 # error Define either SOGTK_DLL or SOGTK_NOT_DLL as appropriate for your linkage! See Inventor/Gtk/SoGtkBasic.h for further instructions. 00142 # endif /* SOGTK_NOT_DLL */ 00143 # endif /* !SOGTK_DLL */ 00144 # endif /* !SOGTK_MAKE_DLL */ 00145 #endif /* Microsoft Windows */ 00146 00147 /* Empty define to avoid errors when _not_ compiling an MSWindows DLL. */ 00148 #ifndef SOGTK_DLL_API 00149 # define SOGTK_DLL_API 00150 #endif /* !SOGTK_DLL_API */ 00151 00152 // ************************************************************************* 00153 // These sanity checks are designed to detect common pitfall errors for 00154 // Microsoft Windows linkage with SoGtk and Coin. 00155 00156 enum SoGtkABIType { 00157 SOGTK_DLL_ABI, SOGTK_LIB_ABI, SOGTK_UNKNOWN_ABI }; 00158 00159 enum SoGtkABIError { 00160 SOGTK_LINKTIME_MISMATCH, SOGTK_LINKSTYLE_MISMATCH, 00161 SOGTK_RUNTIME_MISMATCH }; 00162 00163 // FIXME: use an "is-this-a-DLL-capable-platform" configure check 00164 // and remove the system "#if defined" tests below. 20011203 mortene. 00165 // FIXME: I disabled this because it wasn't inlined in the client app 00166 // but compiled into the library by MSVC++ and with SOWIN_DLL undefined, 00167 // the ABI test always tried the LIB_ABI path. 20020126 larsa 00168 #if 0 && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) 00169 #define SOGTK_SANITY_CHECK(forward_call) \ 00170 if (SoGtk::isDebugLibrary() && \ 00171 SoDB::isInitialized()) \ 00172 SoDebugError::postWarning("SoGtk::init", \ 00173 "unable to verify application linkage sanity " \ 00174 "because Open Inventor has already been " \ 00175 "initialized before SoGtk::init call"); \ 00176 SOGTK_RUNTIME_SANITY_CHECK(); \ 00177 SOGTK_LINKSTYLE_SANITY_CHECK(); \ 00178 forward_call; \ 00179 SOGTK_LINKTIME_SANITY_CHECK() 00180 00181 #define SOGTK_RUNTIME_SANITY_CHECK() \ 00182 do { \ 00183 if (!SoGtk::isCompatible(SOGTK_MAJOR_VERSION, \ 00184 SOGTK_MINOR_VERSION)) \ 00185 SoGtk::abort(SOGTK_RUNTIME_MISMATCH); \ 00186 } while (FALSE) 00187 00188 #ifdef SOGTK_DLL 00189 #define SOGTK_LINKSTYLE_SANITY_CHECK() \ 00190 do { \ 00191 if (SoGtk::getABIType() != SOGTK_DLL_ABI) \ 00192 SoGtk::abort(SOGTK_LINKSTYLE_MISMATCH); \ 00193 } while (FALSE) 00194 #else 00195 #define SOGTK_LINKSTYLE_SANITY_CHECK() \ 00196 do { \ 00197 if (SoGtk::getABIType() != SOGTK_LIB_ABI) \ 00198 SoGtk::abort(SOGTK_LINKSTYLE_MISMATCH); \ 00199 } while (FALSE) 00200 #endif 00201 00202 #define SOGTK_LINKTIME_SANITY_CHECK() \ 00203 do { \ 00204 if (!SoDB::isInitialized()) \ 00205 SoGtk::abort(SOGTK_LINKTIME_MISMATCH); \ 00206 } while (FALSE) 00207 #else /* ! MS Windows */ 00208 #define SOGTK_SANITY_CHECK(forward_call) \ 00209 forward_call 00210 #endif /* ! MS Windows */ 00211 00212 // ************************************************************************* 00213 00214 #endif // ! SOGTK_BASIC_H