stddefns.h

Go to the documentation of this file.
00001 /**
00002 *  mi32/stddefns.h - Standard definitions for MicroImages SDK
00003 *
00004 *  \if NODOC
00005 *  Do not add new types/functions/macros/constants to this file without
00006 *  first discussing the proposed change with the programming team.
00007 *  This file should not reference any other header file.
00008 *
00009 *  $Log: stddefns.h_v $
00010 *  Revision 1.314  2004/11/15 14:44:37  mju
00011 *  Add fast_truncate.
00012 *  Add documentation regarding accuracy of fast_... functions.
00013 *
00014 *  Revision 1.313  2004/11/11 22:18:49  mju
00015 *  Add FAST_CEIL and FAST_FLOOR inlines.
00016 *  Rename ROUND as FAST_ROUND with #define for legacy usages.
00017 *  Tweak round inline to avoid extra fld/fstp instructions.
00018 *
00019 *  Revision 1.312  2004/07/15 13:56:13  dwilliss
00020 *  Define ERRVALUE even if not C++
00021 *
00022 *  Revision 1.311  2004/06/22 20:54:03  mju
00023 *  Move mdlgShowErrorCode here so available for MFC without including mdlg hdr.
00024 *
00025 *  Revision 1.310  2004/06/17 19:37:36  mju
00026 *  Make compiler warning 4258 an error.
00027 *
00028 *  Revision 1.309  2004/05/10 17:09:30  mju
00029 *  Move MGD::PIXEL typedef here.
00030 *
00031 *  Revision 1.308  2004/05/07 16:35:26  mju
00032 *  Add enum operator ^ for toggle of flag bits.
00033 *
00034 *  Revision 1.307  2004/03/11 22:09:52  scowan
00035 *  4702 downgraded to a warning.
00036 *
00037 *  Revision 1.306  2004/03/11 20:29:30  scowan
00038 *  Make 4702 an error for release builds.
00039 *
00040 *  Revision 1.305  2004/03/11 18:48:06  scowan
00041 *  Added more warnings and made one warnings an error.
00042 *
00043 *  Revision 1.304  2004/03/05 18:41:34  mju
00044 *  Comment out warning re static object init not thread-safe.
00045 *
00046 *  Revision 1.303  2004/03/04 20:34:17  scowan
00047 *  Comment const expr warning./
00048 *
00049 *  Revision 1.302  2004/03/04 20:31:53  scowan
00050 *  Added new warning.
00051 *
00052 *  Revision 1.301  2004/03/04 18:50:04  scowan
00053 *  Comment out another warning.
00054 *
00055 *  Revision 1.300  2004/03/04 18:41:10  scowan
00056 *  Comment out two warnings as are redundant.
00057 *
00058 *  Revision 1.299  2004/03/04 17:59:22  scowan
00059 *  Added more warnings and errors.
00060 *
00061 *  Revision 1.298  2004/02/19 17:00:53  mju
00062 *  Don't define use_mgui if defined already.
00063 *
00064 *  Revision 1.297  2004/02/19 15:49:23  mju
00065 *  Define use_mgui for x_native and win32_mfc.
00066 *
00067 *  Revision 1.296  2004/02/16 18:01:26  mju
00068 *  Add DEPRECATED macro so will generate compiler warnings when use deprecated items.
00069 *
00070 *  Revision 1.295  2004/02/16 16:10:11  mju
00071 *  Remove some legacy namespace stuff.
00072 *
00073 *  Revision 1.294  2003/12/26 17:08:21  scowan
00074 *  Promote new warning to an error.
00075 *
00076 *  Revision 1.293  2003/12/24 20:13:05  scowan
00077 *  Added more vc7 fixes.
00078 *
00079 *  Revision 1.292  2003/12/24 18:43:17  scowan
00080 *  Adjusted for vc7.
00081 *
00082 *  Revision 1.291  2003/12/15 21:18:49  mju
00083 *  If deprecate_all then undef other deprecation constants before redefining.
00084 *
00085 *  Revision 1.290  2003/10/28 18:20:12  mju
00086 *  Turn off 4761 error until determine true meaning.
00087 *
00088 *  Revision 1.289  2003/10/24 13:42:58  mju
00089 *  If DEPRECATE_ALL defined then define other deprecation items.
00090 *
00091 *  Revision 1.288  2003/10/22 20:17:05  mju
00092 *  Make 4761 an error.
00093 *
00094 *  Revision 1.287  2003/10/20 16:41:17  mju
00095 *  Make 4551 an error.
00096 *
00097 *  Revision 1.286  2003/10/17 16:00:45  mju
00098 *  Remove obsolete platform references (alpha, msdos).
00099 *
00100 *  Revision 1.285  2003/10/03 20:13:35  linux32build!build
00101 *  Doxygen
00102 *
00103 *  Revision 1.284  2003/09/25 21:29:07  dwilliss
00104 *  Don't capitalize enum any more. Genitor needed it, doxygen doesn't like it.
00105 *
00106 *  Revision 1.283  2003/09/23 20:07:51  dwilliss
00107 *  undefine some constants before we define them.  Some system include was
00108 *  defining them on the Sun
00109 *
00110 *  Revision 1.282  2003/09/15 13:49:56  fileserver!dwilliss
00111 *  Doxygen
00112 *  \endif
00113 **/
00114 
00115 #ifndef INC_MI32_STDDEFNS_H
00116 #define INC_MI32_STDDEFNS_H
00117 
00118 #if !defined(USE_MGUI) && (defined(X_NATIVE) || defined(WIN32_MFC))
00119 #define  USE_MGUI
00120 #endif
00121 
00122 #ifdef DEPRECATE_ALL
00123 #undef   NO_DEPRECATED
00124 #define  NO_DEPRECATED
00125 #undef   DEPRECATE_GROUPKEY
00126 #define  DEPRECATE_GROUPKEY
00127 #undef   DEPRECATE_OLDHELP
00128 #define  DEPRECATE_OLDHELP
00129 #endif
00130 
00131 // Undefine index macro defined on some Unix platforms
00132 #ifdef index
00133 #undef index
00134 #endif
00135 
00136 #ifndef NO_DEPRECATED
00137 // Define ENUM macro to help Starbase Surveyor to document enumerations.
00138 // \deprecated Doxygen doesn't like this and we don't use Surveyor any more.
00139 #define  ENUM enum
00140 #ifdef WIN32
00141 #pragma deprecated("ENUM")
00142 #endif
00143 #endif
00144 
00145 // Fix certain conflicting Windows macros if used.
00146 #if defined(WIN32)
00147 #include <mi32/winfixup.h>
00148 #endif
00149 
00150 #ifndef INC_MI32_DLLDEFNS_H
00151 #include <mi32/dlldefns.h>
00152 #endif
00153 
00154 /*----------------------------------------------------------------------------*/
00155 /*    Define platform definition for compatiblity with existing code          */
00156 /*----------------------------------------------------------------------------*/
00157 
00158 #if defined(WIN32) && !defined(WINNT)
00159    #define  WINNT
00160 #endif
00161 
00162 /*----------------------------------------------------------------------------*/
00163 /*    Platform-specific byte-order definitions                                */
00164 /*----------------------------------------------------------------------------*/
00165 
00166 #if !defined(BYTEORDER_HiLo) && !defined(BYTEORDER_LoHi)
00167    #if defined(i386) || defined(LINUX_INTEL) || defined(NT_INTEL) || defined(WIN32)
00168       #define  BYTEORDER_LoHi
00169    #else
00170       #define  BYTEORDER_HiLo
00171    #endif
00172 #endif
00173 
00174 #if !defined(BYTEORDER_Intel) && defined(BYTEORDER_LoHi)
00175    #define BYTEORDER_Intel
00176 #endif
00177 
00178 /*----------------------------------------------------------------------------*/
00179 /*    Force compile errors for specific warnings                              */
00180 /*----------------------------------------------------------------------------*/
00181 
00182 #if defined(WIN32)
00183    #define DEPRECATED __declspec(deprecated)
00184    // Microsoft visual C/C++ only
00185    #pragma warning (error:4002)  // too many actual parameters for macro
00186    #pragma warning (error:4003)  // not enough actual parameters for macro
00187    #pragma warning (error:4005)  // Macro defined twice
00188    #pragma warning (error:4013)  // Undefined function (missing prototype)
00189    #pragma warning (error:4028)  // Formal parameter different from declaration
00190    #pragma warning (error:4033)  // Function must return a value
00191    #pragma warning (error:4047)  // Different levels of indirection
00192    #pragma warning (error:4098)  // Void function returning a value
00193    #pragma warning (error:4131)  // Function uses old style declarator
00194    #pragma warning (error:4133)  // Incompatible types - from 'unsigned short *' to 'char *'
00195    #pragma warning (error:4150)  // Deletion of pointer to incomplete type
00196    #pragma warning (error:4152)  // Pointer to function converted to pointer to data
00197    #pragma warning (error:4172)  // Returning address of local or temporary
00198    // Next one commented out due to <xmemory> not compiling with it on
00199 // #pragma warning (error:4217)  // 'operator' : member template functions cannot be used for copy-assignment or copy-construction
00200    #pragma warning (error:4218)  // Function does not have a return type
00201    #pragma warning (error:4258)  // Defintion from for loop is ignored, defintion from enclosing scope is used
00202    #pragma warning (error:4288)  // Loop variable used outside of loop
00203    #pragma warning (error:4305)  // Argument truncation from '...' to '...'
00204    #pragma warning (error:4309)  // Truncation of constant value
00205    #pragma warning (error:4390)  // Empty control statement found, no point for it
00206    #pragma warning (error:4545)  // expression before comma evaluates to a function which is missing an argument list
00207    #pragma warning (error:4546)  // function call before comma missing argument list
00208    #pragma warning (error:4547)  // 'operator' : operator before comma has no effect; expected operator with side-effect
00209    #pragma warning (error:4548)  // expression before comma has no effect; expected expression with side-effect
00210    #pragma warning (error:4549)  // 'operator' : operator before comma has no effect; did you intend 'operator'?
00211    #ifdef ALLOW_UNUSED_FUNCTIONS
00212       #pragma warning (3:4505)   // Local function not used
00213    #else
00214       #pragma warning (error:4505) // Local function not used
00215    #endif
00216    #pragma warning (error:4551)  // Function call missing argument list
00217    #pragma warning (error:4552)  // Operator has no effect, expected operator with side effect
00218    #pragma warning (error:4553)  // '==' operator has no effect
00219    #pragma warning (error:4700)  // Local variable used without having been initialized
00220    #pragma warning (error:4715)  // Not all control paths return a value
00221    #pragma warning (error:4717)  // 'method' : recursive on all control paths, function will cause runtime stack overflow.  Not all control paths return a value
00222 // #pragma warning (error:4761)  // Integral size mismatch in argument
00223    #pragma warning (error:4804)  // Unsafe use of type 'bool' in operation
00224    #pragma warning (error:4805)  // Unsafe mix of types for bitwise operation
00225    #pragma warning (error:4806)  // Unsafe operation, no value of type 'bool can equal the given constant
00226    #ifdef WARN_UNREF_PARM
00227       #pragma warning (3:4100)   // Unreferenced formal parameter
00228    #endif
00229 // #pragma warning (3:4127)      // conditional expression is constant
00230    #pragma warning (3:4132)      // 'object' : const object should be initialized
00231    #pragma warning (3:4189)      // Local variable initialized but not referenced
00232    #pragma warning (3:4201)      // Nameless structure / union
00233    #pragma warning (3:4211)      // Redefine extern to static
00234    #pragma warning (3:4212)      // Function declaration uses ellipsis, definition does not
00235    #pragma warning (3:4222)      // 'static' used on member function at file scope
00236    #pragma warning (3:4234)      // Keyword reserved for future use
00237    #pragma warning (3:4235)      // Keyword not supported
00238    #pragma warning (3:4244)      // Conversion results in possible loss of data
00239    #pragma warning (3:4263)      // 'function' : member function does not override any base class virtual member function
00240    #pragma warning (3:4264)      // 'virtual_function' : no override available for virtual member function from base 'class'; function is hidden
00241    #pragma warning (3:4265)      // 'class' : class has virtual functions, but destructor is not virtual
00242    #pragma warning (3:4268)      // 'identifier' : 'const' static/global data initialized with compiler generated default constructor fills the object with zeros
00243    #pragma warning (3:4287)      // 'operator' : unsigned/negative constant mismatch
00244    #pragma warning (3:4295)      // 'array' : array is too small to include a terminating null character
00245    #pragma warning (3:4296)      // 'operator' : expression is always false
00246    #pragma warning (3:4408)      // anonymous union did not declare any data members
00247    #pragma warning (3:4510)      // 'class' : default constructor could not be generated
00248    #pragma warning (3:4515)      // 'namespace' : namespace uses itself
00249    #pragma warning (3:4527)      // instances of type 'class' can never be destroyed - user-defined destructor required
00250    #pragma warning (3:4555)      // expression has no effect; expected expression with side-effect
00251    #pragma warning (3:4610)      // object 'class' can never be instantiated - user-defined constructor required
00252    // Next three commented out due to redundancy with error of actually using a ctor(), copy ctor() or op=()
00253 // #pragma warning (3:4623)      // 'derived class' : default constructor could not be generated because a base class default constructor is inaccessible
00254 // #pragma warning (3:4625)      // 'derived class' : copy constructor could not be generated because a base class copy constructor is inaccessible
00255 // #pragma warning (3:4626)      // 'derived class' : assignment operator could not be generated because a base class assignment operator is inaccessible
00256 // #pragma warning (3:4640)      // 'instance' : construction of local static object is not thread-safe
00257    #pragma warning (3:4701)      // Local variable not initialized
00258    #pragma warning (3:4702)      // Unreachable code
00259    #pragma warning (3:4705)      // Statement has no effect
00260    #pragma warning (3:4706)      // Assignment within conditional expression
00261    #pragma warning (3:4709)      // Comma operator within array brackets
00262    #pragma warning (3:4928)      // illegal copy-initialization; more than one user-defined conversion has been implicitly applied
00263    #pragma warning (3:4946)      // reinterpret_cast used between related classes: 'class1' and 'class2'
00264    #ifdef WARN_NOT_INLINED
00265       #pragma warning (3:4710)      // Function not inlined
00266    #endif
00267    #pragma warning (disable:4284)   // Warning about operator-> with infix notation
00268    #pragma warning (disable:4355)   // 'this' used in base member initializaton list
00269    #pragma warning (disable:4786)   // Browser identifier limit of 255 characters was exceeded, oh well...
00270 #else
00271    #define DEPRECATED
00272 #endif
00273 
00274 /*----------------------------------------------------------------------------*/
00275 /*    Namespace handling macros                                               */
00276 /*----------------------------------------------------------------------------*/
00277 
00278 #if defined(__cplusplus)
00279    #if defined(WIN32)
00280       #define  ALLOW_NAMESPACES
00281       namespace std {}
00282    #endif
00283 #endif
00284 
00285 /*----------------------------------------------------------------------------*/
00286 /*    Platform-independent numeric types                                      */
00287 /*----------------------------------------------------------------------------*/
00288 
00289 typedef signed char              INT8;    // X11/Xmd.h defines it this way too
00290 typedef unsigned char            UINT8;
00291 typedef short                    INT16;
00292 typedef unsigned short           UINT16;
00293 #if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1200)
00294    // Using Microsoft Visual C/C++ 6.0 or higher
00295    #include <basetsd.h>
00296    #define  INT32_is_int   //!< Indicates that INT32 is same type as "int"
00297    typedef int                   PTRINT;
00298    typedef unsigned int          PTRUINT;
00299 #elif defined(LONGS_ARE_64_BIT)
00300    // Note, longs may be 32 or 64 bit on SGI, so we define LONGS_ARE_64_BIT
00301    // if using the 64-bit compiler.
00302    typedef int                   INT32;
00303    typedef unsigned int          UINT32;
00304    typedef long                  INT64;
00305    typedef unsigned long         UINT64;
00306    #define  INT32_is_int   //!< Indicates that INT32 is same type as "int"
00307    typedef long                  PTRINT;
00308    typedef unsigned long         PTRUINT;
00309 #else
00310    typedef long                  INT32;   //!< Some X headers define it this way so must match
00311    typedef unsigned long         UINT32;
00312    typedef long long             INT64;
00313    typedef unsigned long long    UINT64;
00314    typedef long                  PTRINT;
00315    typedef unsigned long         PTRUINT;
00316 #endif
00317 
00318 typedef unsigned int          COLOR32;
00319 
00320 #if defined(__cplusplus)
00321 
00322 const INT8 INT8_MAX = 127;
00323 const INT8 INT8_MIN = -INT8_MAX-1;
00324 const UINT8 UINT8_MAX = 255;
00325 const UINT8 UINT8_MIN = 0;
00326 
00327 const INT16 INT16_MAX = 32767;
00328 const INT16 INT16_MIN = -INT16_MAX-1;
00329 const UINT16 UINT16_MAX = 65535;
00330 const UINT16 UINT16_MIN = 0;
00331 
00332 const INT32 INT32_MAX = 2147483647;
00333 const INT32 INT32_MIN = -INT32_MAX-1;
00334 const UINT32 UINT32_MAX = 4294967295UL;
00335 const UINT32 UINT32_MIN = 0;
00336 
00337 // There's a system include file on Sun that #define these for us.
00338 #undef INT64_MIN
00339 #undef INT64_MAX
00340 #undef UINT64_MIN
00341 #undef UINT64_MAX
00342 
00343 #if defined(WIN32)
00344 //! Maximum value of a 64-bit signed integer
00345 const INT64 INT64_MAX = 0x7FFFFFFFFFFFFFFF;
00346 //! Maximum value of a 64-bit signed unsigned integer
00347 const UINT64 UINT64_MAX = 0xFFFFFFFFFFFFFFFF;
00348 #else
00349 // G++ complains unless we specify LL or ULL
00350 //! Maximum value of a 64-bit signed integer
00351 const INT64 INT64_MAX = 0x7FFFFFFFFFFFFFFFLL;
00352 //! Maximum value of a 64-bit signed unsigned integer
00353 const UINT64 UINT64_MAX = 0xFFFFFFFFFFFFFFFFULL;
00354 #endif
00355 
00356 //! Minimum value of a 64-bit signed integer
00357 const INT64 INT64_MIN = -INT64_MAX-1;
00358 //! Minimum value of a 64-bit signed unsigned integer
00359 const UINT64 UINT64_MIN = 0;
00360 
00361 //! Create two INT32's to INT64 constants
00362 const UINT64 INT64_MULT = static_cast<UINT64>(UINT32_MAX) + 1;
00363 
00364 namespace MGUI {
00365    // Define generic ID for MGUI which is same size as pointer.
00366    typedef PTRINT ID;
00367    }
00368 
00369 namespace MGD {
00370    //! Pixel value on drawing device.
00371    typedef unsigned long PIXEL;
00372    }
00373 
00374 #else // Not C++
00375 
00376 #define INT8_MAX           127
00377 #define INT8_MIN           (-INT8_MAX-1)
00378 #define UINT8_MAX          255
00379 #define UINT8_MIN          0
00380 
00381 #define INT16_MAX          32767
00382 #define INT16_MIN          (-INT16_MAX-1)
00383 #define UINT16_MAX         65535
00384 #define UINT16_MIN         0
00385 
00386 #define INT32_MAX          2147483647
00387 #define INT32_MIN          (-INT32_MAX-1)
00388 #define UINT32_MAX         4294967295
00389 #define UINT32_MIN         0
00390 
00391 #define INT64_MAX          0x7FFFFFFFFFFFFFFF
00392 #define INT64_MIN          (-INT64_MAX-1)
00393 #define UINT64_MAX         0xFFFFFFFFFFFFFFFF
00394 #define UINT64_MIN         0
00395 
00396 #endif
00397 
00398 typedef float FLOAT;
00399 typedef double DOUBLE;
00400 typedef unsigned short UNICODE;
00401 
00402 /*----------------------------------------------------------------------------*/
00403 /*    Declarations (without definitions) for common classes and structures    */
00404 /*----------------------------------------------------------------------------*/
00405 
00406 #if defined(__cplusplus)
00407 
00408 struct WPOINT2D;                 //!< point.h
00409 struct LPOINT2D;                 //!< point.h
00410 struct FPOINT2D;                 //!< point.h
00411 struct DPOINT2D;                 //!< point.h
00412 struct WPOINT3D;                 //!< point.h
00413 struct LPOINT3D;                 //!< point.h
00414 struct FPOINT3D;                 //!< point.h
00415 struct DPOINT3D;                 //!< point.h
00416 struct FPOINT3DH;                //!< point.h
00417 struct DPOINT3DH;                //!< point.h
00418 
00419 
00420 struct WRECT2D;                  //!< rect.h
00421 struct LRECT2D;                  //!< rect.h
00422 struct DRECT2D;                  //!< rect.h
00423 struct DRECT3D;                  //!< rect.h
00424 
00425 typedef WRECT2D WRECTXY;
00426 typedef LRECT2D LRECTXY;
00427 
00428 struct MAPPROJPARM;              //!< mapproj.h
00429 struct RVCGENINFO;               //!< rvcdefns.h
00430 struct FNAMEINODEUC;             //!< rvcdefns.h
00431 
00432 #endif   // C++
00433 
00434 
00435 /*----------------------------------------------------------------------------*/
00436 /*    Coordinate data type definitions                                        */
00437 /*----------------------------------------------------------------------------*/
00438 
00439 #if defined(__cplusplus)
00440 
00441 struct WPOLYGON { INT32 numpts; WPOINT2D *point; };
00442 struct LPOLYGON { INT32 numpts; LPOINT2D *point; };
00443 struct DPOLYGON { INT32 numpts; DPOINT2D *point; };
00444 
00445 typedef WPOLYGON WPOLYLINE;
00446 typedef LPOLYGON LPOLYLINE;
00447 typedef DPOLYGON DPOLYLINE;
00448 
00449 struct DPOLYLINE3D { INT32 numpts; DPOINT3D *point; };
00450 
00451 struct LSEGMENT2D { INT32 x1, y1, x2, y2; };
00452 
00453 #endif   // C++
00454 
00455 /*----------------------------------------------------------------------------*/
00456 /*    Miscellaneous types                                                     */
00457 /*----------------------------------------------------------------------------*/
00458 
00459 typedef int ERRVALUE;               //!< Return type value, signifies < 0 is an error
00460 
00461 // NOTE: ERRVALUE must be defined even if not C++.  The freetype13 library,
00462 // when compiled for Mac OS X, has a module we wrote to read resource forks
00463 // This module includes miodefns.h, which uses ERRVALUE.  Freetype13 is not
00464 // a C++ library.  So to whoever put it in the cplusplus only section below...
00465 //   PTHATHATHATHATH!
00466 
00467 #if defined(__cplusplus)
00468 
00469 struct DRANGE { double min, max; };
00470 
00471 typedef UINT32 ICID;          //!< Interface component ID
00472 
00473 typedef INT32 RVCINODENUM;          //!< Type for RVC Object Inode parameter
00474 typedef int (*MfFiltFuncProto) (int, RVCINODENUM, RVCGENINFO*, void*, char*);
00475 typedef int (*MfValidMultiProto) (int, FNAMEINODEUC*, void*, int*, char*);
00476 
00477 typedef struct _WidgetRec *Widget;
00478 
00479 #ifdef WIN32_NATIVE
00480    #if defined(__cplusplus)
00481       class CWnd;
00482       typedef CWnd* MDLGPARENT;
00483    #endif
00484 #else
00485    #ifndef X_NATIVE
00486       #define  X_NATIVE
00487    #endif
00488    typedef Widget MDLGPARENT;
00489    #ifdef WIN32
00490       typedef unsigned long COLORREF;
00491    #else
00492       typedef UINT32 COLORREF;
00493    #endif
00494 #endif
00495 
00496 typedef DOUBLE Mat3x3[3][3];
00497 typedef DOUBLE MAT3X3[3][3];
00498 typedef DOUBLE MAT4X4[4][4];
00499 
00500 typedef void *INIHANDLE;            //!< Ini access handle
00501 typedef void *MXDHANDLE;            //!< Generic dialog handle
00502 typedef unsigned long MPIXEL;       //!< Generic "pixel" value
00503 
00504 
00505 /*----------------------------------------------------------------------------*/
00506 /*    Miscellaneous constants                                                 */
00507 /*----------------------------------------------------------------------------*/
00508 
00509 #ifdef FALSE
00510 #undef FALSE
00511 #endif
00512 #define FALSE  0
00513 #ifdef TRUE
00514 #undef TRUE
00515 #endif
00516 #define TRUE   1
00517 
00518 #ifndef NULL
00519 #define NULL 0
00520 #endif
00521 
00522 #ifdef PI            // LINUX defined this
00523 #undef PI
00524 #endif
00525 #define  PI          (3.14159265358979323846)
00526 #define  RADTODEG    (180.0/PI)
00527 #define  DEGTORAD    (PI/180.0)
00528 #define  RADTODEG64  (64.0*180.0/PI)
00529 #define  DEG64TORAD  (PI/(64.0*180.0))
00530 
00531 #define  FEETTOMETERS   (0.3048)
00532 #define  METERSTOFEET   (3.280839895)
00533 #define  METERSTOINCHES (3.280839895*12.0)
00534 
00535 #if defined(WIN32) && !defined(WIN32_NATIVE)
00536    #ifndef  NeedFunctionPrototypes
00537       #define  NeedFunctionPrototypes  1
00538    #endif
00539    #ifndef  XTSTRINGDEFINES
00540       #define  XTSTRINGDEFINES
00541    #endif
00542    #ifndef  XMSTRINGDEFINES
00543       #define  XMSTRINGDEFINES
00544    #endif
00545    #ifndef  XmHTML_STRINGDEFINES
00546       #define  XmHTML_STRINGDEFINES
00547    #endif
00548 #endif
00549 
00550 /*----------------------------------------------------------------------------*/
00551 /*    Miscellaneous macros                                                    */
00552 /*----------------------------------------------------------------------------*/
00553 
00554 #ifdef MIN
00555 #undef MIN
00556 #endif
00557 #ifdef MAX
00558 #undef MAX
00559 #endif
00560 
00561 #ifndef membersize
00562    #define  membersize(type,name)   sizeof(((type*)0)->name)
00563 #endif
00564 
00565 #define  ARRAYSIZE(a)   (sizeof(a)/sizeof(a[0]))
00566 #define  MIN(i1,i2)     (((i1)<(i2))?(i1):(i2))
00567 #define  MAX(i1,i2)     (((i1)>(i2))?(i1):(i2))
00568 #define  SIGN(d)        (((d)<0) ? -1 : ((d)>0) ? 1 : 0)
00569 #define  SWAP(a,b)      { a-=b; b+=a; a=b-a; }
00570 #define  bound(val,min,max)   (((val)<(min))?(min):(((val)>(max))?(max):(val)))
00571 
00572 #if defined(WIN32) && defined(__cplusplus)
00573 
00574 // On Intel, avoid the _ftol() call implied by the cast to integer.
00575 // ftol() is slow because of the way it casts.  It first has to switch
00576 // the conversion mode of the processor from round to truncate, which
00577 // cuases all pipelines to stall.  Then it converts the number and switches
00578 // back to rounding mode.  That's a lot of work to truncate a number when
00579 // the default would have been to do What We Wanted (W3)
00580 // Accounts for Intel rounding .5 values to nearest -even- integer, corrects for up to +/- 1000000
00581 
00582 //! Fast round of value to nearest integer, with X.5 values rounded up.
00583 //! This function is approximately 3X faster than using static_cast<INT32>(x+.5) on Intel.
00584 //! Accuracy limitations:
00585 //! Values in the range from -1000000 to +1000000 at exactly .5 will be handled correctly.
00586 //! Values outside that range may not always be rounded up.  In addition, values in the
00587 //! range of -1000 to 1000 which are within 1E-10 of .5 may not be correctly rounded down.
00588 //! The FAST_... functions should not be used if exact accuracy is required.
00589 inline INT32 FAST_ROUND (double x) {
00590    static const double d = 1E-10;
00591    INT32 result;
00592    __asm fld x
00593    __asm fadd d
00594    __asm fistp result
00595    return result;
00596    }
00597 
00598 //! Fast return of smallest integer greater than or equal to specified value.
00599 //! This function is at least 5X faster than using static_cast<INT32>(ceil(x)) on Intel.
00600 //! Accuracy limitations:
00601 //! Values in the range from -1000000 to +1000000 at exactly .0 will be handled correctly.
00602 //! Values outside that range may not always be correct.  In addition, values in the
00603 //! range of -1000 to 1000 which are within 1E-10 of .0 may not be correctly rounded.
00604 //! The FAST_... functions should not be used if exact accuracy is required.
00605 inline INT32 FAST_CEIL (double x) {
00606    static const double d = .4999999999;
00607    INT32 result;
00608    __asm fld x
00609    __asm fadd d
00610    __asm fistp result
00611    return result;
00612    }
00613 
00614 //! Fast return of largest integer less than or equal to specified value.
00615 //! This function is at least 5X faster than using static_cast<INT32>(floor(x)) on Intel.
00616 //! Accuracy limitations:
00617 //! Values in the range from -1000000 to +1000000 at exactly .0 will be handled correctly.
00618 //! Values outside that range may not always be correct.  In addition, values in the
00619 //! range of -1000 to 1000 which are within 1E-10 of .0 may not be correctly rounded.
00620 //! The FAST_... functions should not be used if exact accuracy is required.
00621 inline INT32 FAST_FLOOR (double x) {
00622    static const double d = -.4999999999;
00623    INT32 result;
00624    __asm fld x
00625    __asm fadd d
00626    __asm fistp result
00627    return result;
00628    }
00629 
00630 //! Fast return of largest integer less than or equal to specified value.
00631 //! This function is at approximately 3X faster than using static_cast<INT32>(x) on Intel.
00632 //! If values are known to always be positive (or negative) it will be faster to
00633 //! use the FAST_FLOOR (or FAST_CEIL) function as appropriate.
00634 //! Accuracy limitations:
00635 //! Values in the range from -1000000 to +1000000 at exactly .0 will be handled correctly.
00636 //! Values outside that range may not always be correct.  In addition, values in the
00637 //! range of -1000 to 1000 which are within 1E-10 of .0 may not be correctly rounded.
00638 //! The FAST_... functions should not be used if exact accuracy is required.
00639 inline INT32 FAST_TRUNCATE (double x) {
00640    static const double d = .4999999999;
00641    INT32 result;
00642    if (x < 0) {
00643       __asm fld x
00644       __asm fadd d
00645       __asm fistp result
00646       }
00647    else {
00648       __asm fld x
00649       __asm fsub d
00650       __asm fistp result
00651       }
00652    return result;
00653    }
00654 
00655 
00656 #else
00657 
00658 #define  FAST_ROUND(d)     static_cast<INT32>(floor((d)+.5))
00659 #define  FAST_CEIL(d)      static_cast<INT32>(ceil(d))
00660 #define  FAST_FLOOR(d)     static_cast<INT32>(floor(d))
00661 #define  FAST_TRUNCATE(d)  static_cast<INT32>(d)
00662 
00663 #endif
00664 
00665 #define  ROUND FAST_ROUND
00666 
00667 #if defined(__cplusplus)
00668 
00669 //! Compile-time validate size of structure or class
00670 #define  CHECKSIZE(s) \
00671    inline int _checksize () { return (1 / ((sizeof(*this) == (s)) ? 1 : 0)); }
00672 
00673 //! Compile-time validate that public global has a matching prototype.
00674 #if defined(WIN32) && !defined(VC7)    // VC 7 causes ERRVALUE GLOBALFUNC GetLastErrCode() to be interpreted as ERRVALUE::GetLastErrCode()
00675 #define  GLOBALFUNC  ::
00676 #else
00677 #define  GLOBALFUNC        
00678 #endif
00679 
00680 //! Set or clear 'bit' in value based on 'bool'.
00681 //! The type may be an enum if DEFINE_ENUM_OP_BITWISE used on enum.
00682 template <class _CT> inline void SetBitFromBool (
00683    _CT& value,       //!< Value to modify
00684    unsigned bit,     //!< Bit(s) to set or clear.
00685    bool set          //!< 'true' to set, 'false' to clear
00686    ) { if (set) value |= static_cast<_CT>(bit); else value &= static_cast<_CT>(~bit); }
00687 
00688 inline void SetMinMax (double x, double& minx, double& maxx) { if (x < minx) minx = x;  if (x > maxx) maxx = x;}
00689 inline void SetMinMax (INT32 x, INT32& minx, INT32& maxx) { if (x < minx) minx = x;  if (x > maxx) maxx = x;}
00690 inline void SetMinMax (UINT32 x, UINT32& minx, UINT32& maxx) { if (x < minx) minx = x;  if (x > maxx) maxx = x;}
00691 
00692 //! Functions to convert two INT32's to an INT64
00693 inline INT64 INT32ToINT64 (INT32 high, INT32 low) {INT64 retval = high; return ((retval << 32) + low);};
00694 inline UINT64 UINT32ToUINT64 (UINT32 high, UINT32 low) {UINT64 retval = high; return ((retval << 32) + low);};
00695 #if defined(WIN32)
00696 inline void INT64ToINT32 (INT64 value, INT32& high, INT32& low) {low = static_cast<INT32>(value & 0x00000000FFFFFFFF); high = static_cast<INT32>(value >> 32); return;};
00697 inline void UINT64ToUINT32 (UINT64 value, UINT32& high, UINT32& low) {low = static_cast<UINT32>(value & 0x00000000FFFFFFFF); high = static_cast<UINT32>(value >> 32); return;};
00698 #else
00699 inline void INT64ToINT32 (INT64 value, INT32& high, INT32& low) {low = static_cast<INT32>(value & 0x00000000FFFFFFFFLL); high = static_cast<INT32>(value >> 32); return;};
00700 inline void UINT64ToUINT32 (UINT64 value, UINT32& high, UINT32& low) {low = static_cast<UINT32>(value & 0x00000000FFFFFFFFULL); high = static_cast<UINT32>(value >> 32); return;};
00701 #endif
00702 
00703 #ifndef GENERATING_DOXYGEN_OUTPUT
00704 
00705 //! Define bitwise &, |, +, -, ^ operators for enumerations (for use as flags).
00706 #define  DEFINE_ENUM_OP_BITWISE(_CT) \
00707    inline _CT operator| (const _CT& lhs, const _CT& rhs) \
00708       { return (static_cast<_CT>(static_cast<const INT32>(lhs) | static_cast<const INT32>(rhs))); } \
00709    inline _CT& operator|= (_CT& lhs, const _CT& rhs) \
00710       { lhs = (static_cast<_CT>(static_cast<INT32>(lhs) | static_cast<const INT32>(rhs))); return (lhs); } \
00711    inline _CT& operator+= (_CT& lhs, const _CT& rhs) \
00712       { lhs = (static_cast<_CT>(static_cast<INT32>(lhs) | static_cast<const INT32>(rhs))); return (lhs); } \
00713    inline _CT operator& (const _CT& lhs, const _CT& rhs) \
00714       { return (static_cast<_CT>(static_cast<const INT32>(lhs) & static_cast<const INT32>(rhs))); } \
00715    inline _CT& operator&= (_CT& lhs, const _CT& rhs) \
00716       { lhs = (static_cast<_CT>(static_cast<INT32>(lhs) & static_cast<const INT32>(rhs))); return (lhs); } \
00717    inline _CT operator- (const _CT& lhs, const _CT& rhs) \
00718       { return (static_cast<_CT>(static_cast<const INT32>(lhs) & static_cast<const INT32>(~rhs))); } \
00719    inline _CT& operator-= (_CT& lhs, const _CT& rhs) \
00720       { lhs = (static_cast<_CT>(static_cast<INT32>(lhs) & static_cast<const INT32>(~rhs))); return (lhs); } \
00721    inline _CT operator^ (const _CT& lhs, const _CT& rhs) \
00722       { return (static_cast<_CT>(static_cast<const INT32>(lhs) ^ static_cast<const INT32>(rhs))); } \
00723    inline _CT& operator^= (_CT& lhs, const _CT& rhs) \
00724       { lhs = (static_cast<_CT>(static_cast<INT32>(lhs) ^ static_cast<const INT32>(rhs))); return (lhs); }
00725 #define  DEFINE_ENUM_OPERATORS   DEFINE_ENUM_OP_BITWISE
00726 
00727 //! Define increment (++) operator for enumerations.
00728 #define  DEFINE_ENUM_OP_INCREMENT(_CT) \
00729    inline _CT& operator++ (_CT& lhs) { lhs = static_cast<_CT>(lhs+1); return (lhs); }
00730 
00731 #endif // GENERATING_DOXYGEN_OUTPUT
00732 
00733 #else    // not C++
00734 
00735 #define  CHECKSIZE(s)
00736 #define  bool int
00737 
00738 #endif   // C++
00739 
00740 #if defined(USE_AMEMCPY) && defined(WIN32)
00741 //! For testing: If you define USE_AMEMCPY in your makefile, all memcpy
00742 //! calls will be replaced with our accelerated versions (Windows only,
00743 //! other platforms either don't have MMX or I don't know the inline
00744 //! assembler syntax of the compiler),  This may eventually go away
00745 //! in favor of some new method, `cause Mike won't like this.
00746 
00747 #include <memory.h>        //! Make sure we have memcpy prototyped...
00748 #include <mi32/cpuext.h>   //! Define our prototype...
00749 #define memcpy amemcpy     //!< override memcpy with our accelerated version
00750 #endif
00751 
00752 
00753 /*----------------------------------------------------------------------------*/
00754 
00755 #if defined(__cplusplus)
00756 #ifndef GENERATING_DOXYGEN_OUTPUT
00757 
00758 // Macro to prevent use of memset/memcpy/memcmp on pointer to specified type.
00759 #ifdef memcpy
00760 // Assume defined as 'amemcpy' so need definition to match
00761 #define  PREVENT_MEMFUNC(type) \
00762    void memcmp(type *, const type *, int); \
00763    extern void* (*amemcpy)(type *, const type *, int); \
00764    void memset(type *, int, int);
00765 #else
00766 #define  PREVENT_MEMFUNC(type) \
00767    void memcmp(type *, const type *, int); \
00768    void memcpy(type *, const type *, int); \
00769    void memset(type *, int, int);
00770 #endif
00771 
00772 // Macro to prevent use of memcmp on pointer of specified type.
00773 #define  PREVENT_MEMCMP(type) \
00774    void memcmp(type *, const type *, int);
00775 
00776 #endif // GENERATING_DOXYGEN_OUTPUT
00777 #endif   //  __cplusplus 
00778 
00779 /*----------------------------------------------------------------------------*/
00780 
00781 //!\addtogroup mdlg Mdlg functions
00782 //!@{
00783 
00784 //! Display error dialog with text for specified error code.
00785 //! @return error code or EUserCancel.
00786 //! Similar to MdlgShowMessageCode(parent,errcode,MDLG_MESSAGETYPE_Error) except
00787 //! that EUserCancel messages are not displayed.
00788 ERRVALUE MdlgShowErrorCode (
00789    MDLGPARENT parent,                  //!< Parent for dialog, NULL for default
00790    ERRVALUE errcode                    //!< Error code
00791    );
00792 
00793 //!@}
00794 
00795 #endif   // C++
00796 
00797 #endif   // #ifndef INC_MI32_STDDEFNS_H

Generated on Tue Dec 14 13:18:38 2004 for TNTsdk by  doxygen 1.3.8-20040913