This mail went to FLTK.bugs. Forwarded it to FLTK.developers where it belongs.

As for the contents, I don't know enough about this. Manolo?

Begin forwarded message:

> From: Jarno Rajahalme <[email protected]>
> Date: 21. Dezember 2010 17:12:55 MEZ
> To: [email protected]
> Cc: [email protected]
> Subject: [fltk.bugs] FLTK on OSX to compile with non-Apple G++ (patch 
> included)
> Reply-To: "Mirror of fltk.bugs Newsgroup" <[email protected]>
> 
> Problem:
> 1. On OSX, FLTK (1.3) includes draw in OSX specific Objective-C/C++ 2.0 
> include files, that can only be compiled with Apple supplied GCC variants. 
> Apple-GCC  seems to be stuck at versions 4.0 and 4.2.
> 
> 2. The included OSX headers also cause name collisions with some software 
> that has not been designed to include OSX-specific header files. For example, 
> there is a name collision with "Cell" as defined by the included OSX headers 
> and "Cell" defined in GNU Octave. This at least when compiling 64-bit, have 
> not tested this with 32-bit.
> 
> 3. It would be great if it was possible to use FLTK also with non-Apple GCC 
> versions, especially when compiling portable (non-OSX) code, that relies on 
> FLTK for UI portability (which I presume is the whole point with FLTK !)
> 
> Solution:
> 
> Obviously FLTK needs to USE Objective-C to implement the OSX specific stuff, 
> but that should not be exposed to the user of FLTK. I found out that FLTK 
> file FL/mac.H includes <Carbon/Carbon.h>, even though the definitions in that 
> file only use a very, very small fraction of the stuff drawn in. In the same 
> spirit that FL/mac.H already defined CGFloat (if needed), I tested if the few 
> needed definitions could be done in FL/mac.H directly, so that FLTK 
> applications would not have to compiled with a Objective-C 2.0 compatible 
> compiler.
> 
> The resulting FL/mac.H diff is below. To use FLTK without including OSX 
> includes, you should have the symbol __CARBON__ defined. For compiling GNU 
> Octave I added "-D__CARBON__" into FLTK_CFLAGS in Octave's configure.ac. 
> Having __CARBON__ defined makes #include <Carbon/Carbon.h> (in FL/mac.H) to 
> have no effect and the additions to FL/mac.H (below) kick in.
> 
> Obviously, when compiling FLTK itself (with Apple GCC, no less), "__CARBON__" 
> should not be defined in advance. In this case none of the changes in 
> FL/mac.H have any effect.
> 
> With these changes the above mentioned "Cell" symbol clash also disappears 
> (as OSX headers are not included), and Octave compiles and runs with FLTK 
> backend, even when compiled with non-Apple GCC.
> 
> Now I have exactly the same behavior for FLTK as before using Apple GCC 4.2, 
> but now using GCC 4.5.1 instead.
> 
> Please feel free to add these changes to FLTK, if you see portable support 
> for non-Apple compilers useful in OSX.
> 
> Regards,
> 
>  Jarno Rajahalme
> 
> 
> Diffs from a recent weekly FLTK 1.3 shapshot (8048) FL/mac.H:
> 
> $ diff -c fltk-1.3.x-r8048/FL/mac.H /opt/local/include/FL/mac.H
> *** fltk-1.3.x-r8048/FL/mac.H Wed Dec  1 19:48:59 2010
> --- /opt/local/include/FL/mac.H       Tue Dec 21 13:56:41 2010
> ***************
> *** 50,56 ****
>  #define MAC_OS_X_VERSION_10_6 1060
>  #endif
>  #ifndef MAC_OS_X_VERSION_MAX_ALLOWED
> ! #define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_3
>  #endif
> 
>  #ifndef CGFLOAT_DEFINED //appears with 10.5 in CGBase.h
> --- 50,56 ----
>  #define MAC_OS_X_VERSION_10_6 1060
>  #endif
>  #ifndef MAC_OS_X_VERSION_MAX_ALLOWED
> ! #define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_6
>  #endif
> 
>  #ifndef CGFLOAT_DEFINED //appears with 10.5 in CGBase.h
> ***************
> *** 61,66 ****
> --- 61,102 ----
>  #endif
>  #endif // CGFLOAT_DEFINED
> 
> + #ifndef CGGEOMETRY_H_ // CoreGraphics/CGGeometry.h
> + struct CGPoint {
> +   CGFloat x;
> +   CGFloat y;
> + };
> + typedef struct CGPoint CGPoint;
> + struct CGSize {
> +   CGFloat width;
> +   CGFloat height;
> + };
> + typedef struct CGSize CGSize;
> + struct CGRect {
> +   CGPoint origin;
> +   CGSize size;
> + };
> + typedef struct CGRect CGRect;
> + #endif /* CGGEOMETRY_H_ */
> + 
> + #ifndef CGCONTEXT_H_ // CoreGraphics/CGContext.h
> + typedef struct CGContext *CGContextRef;
> + #endif      /* CGCONTEXT_H_ */
> + 
> + #ifndef CGIMAGE_H_ // CoreGraphics/CGImage.h
> + typedef struct CGImage *CGImageRef;
> + #endif      /* CGIMAGE_H_ */
> + 
> + #ifndef __QUICKDRAWTYPES__ // QD/QuickdrawTypes.h
> + typedef struct OpaqueWindowPtr* WindowPtr;
> + typedef WindowPtr WindowRef;
> + struct RGBColor {
> +   unsigned short red;
> +   unsigned short green;
> +   unsigned short blue;
> + };
> + typedef struct RGBColor RGBColor;
> + #endif /* __QUICKDRAWTYPES__ */
> 
>  // Now make some fixes to the headers...
>  #undef check                 // Dunno where this comes from...
> 
> 
> 
> _______________________________________________
> fltk-bugs mailing list
> [email protected]
> http://lists.easysw.com/mailman/listinfo/fltk-bugs

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to