Compile errors with JUCE and FLTK

Hi there,


I'm trying to compile a small test program which uses JUCE along with FLTK (, both latest versions, on Ubuntu 14.04 with gcc 4.8.4. Unfortunately I get this error:

In file included from /usr/include/X11/Xlib.h:44:0,
                 from /usr/local/include/FL/fl_utf8.h:63,
                 from /usr/local/include/FL/Fl.H:30,
modules/juce_audio_processors/../juce_gui_basics/keyboard/juce_KeyPress.h:37:17: error: expected identifier before numeric constant
 class JUCE_API  KeyPress
modules/juce_audio_processors/../juce_gui_basics/keyboard/juce_KeyPress.h:37:17: error: expected unqualified-id before numeric constant error: expected ‘}’ at end of input

The include order is as follow:

#include "JuceHeader.h"   <--- which in turn includes AppConfig.h
#include <FL/Fl.H>        <--- FLTK stuff
#include <FL/Fl_Window.H> <--- FLTK stuff

The app compiles fine if I remove FLTK includes: I'm quite sure there's some name clashing here... To solve it, just do

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#undef KeyPress           <--- add this
#include "JuceHeader.h"

Smarter solutions are welcome :)

Without wanting to be rude about the makers of other libraries.. jeez.. defining a macro like "KeyPress" is just a terrible thing to do in a C++ library!

If you look inside juce_StandardHeader.h there's a "hall of shame" where we undef various other stupid 3rd-party macros that cause problems like this. If you could let me know whether adding #undef KeyPress to that list fixes your problem, then I'll add it.

Hi jules,

I totally understand! Thanks for your quick reply, I can confirm that adding  #undef KeyPress inside juce_StandardHeader.h fixes the issue. 

Thanks for letting us know - should be OK now!