|
|
1.1 ! root 1: Compiling Fresco with g++ 2.6 ! 2: ----------------------------- ! 3: ! 4: Fresco is an evolving interface and toolkit for object-oriented ! 5: graphics. A preliminary version (written in C++) was released ! 6: with x11r6. ! 7: ! 8: G++ 2.5.x had various bugs preventing Fresco from compiling properly. ! 9: We believe these have all been fixed in g++ 2.6. However, there ! 10: are still a few portability problems in Fresco itself. These should ! 11: be fixed in the next release of Fresco. ! 12: ! 13: The following patches should help in working around the problems. ! 14: I used these patches when I built Fresco, but I don't have time ! 15: right now to verify them, or to check that they would apply cleanly. ! 16: Perhaps someone could verify these patches against gcc 2.6 and ! 17: the latest Fresco and clean it up? ! 18: ! 19: The most obvious problem is that Fresco defines false and true as constants. ! 20: However, these are noe reserved words in ANSI C++. Since g++ has ! 21: implemented false, true, and bool, it complains about a syntax error. ! 22: ! 23: The first patch below to workInProgress/Fresco/include/Ox/base.h should ! 24: fix that. It also enables use of long long. ! 25: ! 26: I ran into the same "true/false" problem in some other file, ! 27: but I can find it now. (It was not in the library proper.) ! 28: ! 29: The second patch is to contrib/programs/dish/main.cxx. ! 30: The first part of it is probably SunOS4-specific. ! 31: It was somewhat puzzling, but it looks like the %p format conversion ! 32: specifier in either sscanf or sprintf doesn't work properly, so I had to ! 33: use (the less strictly correct) %x specifier. ! 34: ! 35: The other part is also Sun-specific. The original code assumes ! 36: it can call _main, but g++ does not provide that. Instead, I changed ! 37: the code to use a static destructor. The fix in the next Fresco ! 38: release will probably be different. ! 39: ! 40: Please try these patches, and let me know how they work. ! 41: ! 42: --Per Bothner ! 43: Cygnus Support [email protected] ! 44: ! 45: *** /cygint/x11r6/workInProgress/Fresco/include/Ox/base.h Fri Apr 1 13:49:59 1994 ! 46: --- ./base.h Thu May 19 21:02:24 1994 ! 47: *************** ! 48: *** 39,58 **** ! 49: #ifndef ox_Boolean ! 50: #define ox_Boolean ! 51: ! 52: ! typedef unsigned char Boolean; ! 53: ! ! 54: ! static const unsigned char false = 0; ! 55: ! static const unsigned char true = 1; ! 56: ! 57: #ifndef TRUE ! 58: #define TRUE true ! 59: #endif ! 60: - ! 61: #ifndef FALSE ! 62: #define FALSE false ! 63: #endif ! 64: ! 65: ! #endif ! 66: ! 67: #ifndef ox_octet ! 68: #define ox_octet ! 69: --- 39,68 ---- ! 70: #ifndef ox_Boolean ! 71: #define ox_Boolean ! 72: ! 73: ! /* Note that 'bool', 'false', and 'true' are now reserved words in ! 74: ! ANSI/ISO C++, though few compilers implement them. */ ! 75: ! #ifndef __GNUC__ ! 76: ! #ifndef false ! 77: ! #define false 0 ! 78: ! #endif ! 79: ! #ifndef true ! 80: ! #define true 1 ! 81: ! #endif ! 82: ! #ifndef bool ! 83: ! #define bool unsigned char ! 84: ! #endif ! 85: ! #endif ! 86: ! 87: + /* Note: Avoid obsolete identifiers Boolean/TRUE/FALSE. */ ! 88: #ifndef TRUE ! 89: #define TRUE true ! 90: #endif ! 91: #ifndef FALSE ! 92: #define FALSE false ! 93: #endif ! 94: + typedef bool Boolean; ! 95: ! 96: ! #endif /*!ox_Boolean*/ ! 97: ! 98: #ifndef ox_octet ! 99: #define ox_octet ! 100: *************** ! 101: *** 85,91 **** ! 102: #else ! 103: typedef long Long; ! 104: typedef unsigned long ULong; ! 105: ! #if defined(sgi) ! 106: /* compiler supports long long */ ! 107: typedef long long LongLong; ! 108: typedef unsigned long long ULongLong; ! 109: --- 95,101 ---- ! 110: #else ! 111: typedef long Long; ! 112: typedef unsigned long ULong; ! 113: ! #if defined(sgi) || defined (__GNUC__) ! 114: /* compiler supports long long */ ! 115: typedef long long LongLong; ! 116: typedef unsigned long long ULongLong; ! 117: ! 118: *** main.cxx.orig Mon Apr 11 16:25:30 1994 ! 119: --- main.cxx.new Sat May 14 12:48:09 1994 ! 120: *************** ! 121: *** 251,264 **** ! 122: if (strcmp(s, "0") == 0) { ! 123: obj = nil; ! 124: } else { ! 125: ! b = sscanf(s, "_dish_%p", &obj) == 1; ! 126: } ! 127: return b; ! 128: } ! 129: ! 130: char* Dish::object_to_string(BaseObjectRef obj, char* result) { ! 131: if (is_not_nil(obj)) { ! 132: ! sprintf(result, "_dish_%p", obj); ! 133: } else { ! 134: sprintf(result, "0"); ! 135: } ! 136: --- 251,268 ---- ! 137: if (strcmp(s, "0") == 0) { ! 138: obj = nil; ! 139: } else { ! 140: ! long val; ! 141: ! b = sscanf(s, "_dish_%lx", &val) == 1; ! 142: ! if (b) ! 143: ! obj = (BaseObjectRef)(void*)val; ! 144: } ! 145: return b; ! 146: } ! 147: ! 148: char* Dish::object_to_string(BaseObjectRef obj, char* result) { ! 149: if (is_not_nil(obj)) { ! 150: ! long val = (long)obj; ! 151: ! sprintf(result, "_dish_%lx", val); ! 152: } else { ! 153: sprintf(result, "0"); ! 154: } ! 155: *************** ! 156: *** 1087,1110 **** ! 157: } ! 158: } ! 159: ! 160: ! /* ! 161: ! * Called by main() defined in tcl lib. ! 162: ! */ ! 163: ! 164: #if defined(sun) && !defined(SVR4) ! 165: extern "C" { ! 166: void _main(); ! 167: void on_exit(void (*)(), caddr_t); ! 168: } ! 169: #endif ! 170: ! 171: int Tcl_AppInit(Tcl_Interp* interp) { ! 172: #if defined(sun) && !defined(SVR4) ! 173: _main(); ! 174: on_exit(&Dish::cleanup, NULL); ! 175: #else ! 176: atexit(&Dish::cleanup); ! 177: #endif ! 178: Dish* dish = new Dish(interp); ! 179: dish->add_commands(interp); ! 180: dish->add_variables(interp); ! 181: --- 1091,1129 ---- ! 182: } ! 183: } ! 184: ! 185: ! #if !defined(DISH_CLEANUP_USE_DESTRUCTOR) && defined(__GNUC__) ! 186: ! /* This assumes that the tcl library's main() has also been ! 187: ! compiled with gcc, or else the destructors won't get run properly. */ ! 188: ! #define DISH_CLEANUP_USE_DESTRUCTOR 1 ! 189: ! #endif ! 190: ! 191: + #if DISH_CLEANUP_USE_DESTRUCTOR ! 192: + struct DishCleanup { ! 193: + ~DishCleanup() { Dish::cleanup(); } ! 194: + }; ! 195: + static DishCleanup DishCleanupObject; ! 196: + #else /* !DISH_CLEANUP_USE_DESTRUCTOR */ ! 197: #if defined(sun) && !defined(SVR4) ! 198: extern "C" { ! 199: void _main(); ! 200: void on_exit(void (*)(), caddr_t); ! 201: } ! 202: #endif ! 203: + #endif /* !DISH_CLEANUP_USE_DESTRUCTOR */ ! 204: + ! 205: + /* ! 206: + * Called by main() defined in tcl lib. ! 207: + */ ! 208: ! 209: int Tcl_AppInit(Tcl_Interp* interp) { ! 210: + #if !DISH_CLEANUP_USE_DESTRUCTOR ! 211: #if defined(sun) && !defined(SVR4) ! 212: _main(); ! 213: on_exit(&Dish::cleanup, NULL); ! 214: #else ! 215: atexit(&Dish::cleanup); ! 216: #endif ! 217: + #endif /* !DISH_CLEANUP_USE_DESTRUCTOR */ ! 218: Dish* dish = new Dish(interp); ! 219: dish->add_commands(interp); ! 220: dish->add_variables(interp);
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.