dear gcc/g++ and fltk programers:
last time's error is gone, after i copy the newest GUI files download from Mr. 
Stroustrup's website.  But make still not work, especially
reference to window is ambiguous
which conflict with same name declared in X window, plz help

graphic_lib was declared in GUI.h as following
----------------


//

// This is a GUI support code to the chapters 12-16 of the book

// "Programming -- Principles and Practice Using C++" by Bjarne Stroustrup

//



#ifndef GUI_GUARD

#define GUI_GUARD



#include "Window.h"

#include "Graph.h"



namespace Graph_lib {



//------------------------------------------------------------------------------



    typedef void* Address;    // Address is a synonym for void*

    typedef void(*Callback)(Address, Address);    // FLTK's required function 
type for all callbacks



//------------------------------------------------------------------------------



    template<class W> W& reference_to(Address pw)

    // treat an address as a reference to a W

    {

        return *static_cast<W*>(pw);

    }



//------------------------------------------------------------------------------



    class Widget {

    // Widget is a handle to an Fl_widget - it is *not* an Fl_widget

    // We try to keep our interface classes at arm's length from FLTK

    public:

        Widget(Point xy, int w, int h, const string& s, Callback cb)

            : loc(xy), width(w), height(h), label(s), do_it(cb)

        {}



        virtual void move(int dx,int dy) { hide(); pw->position(loc.x+=dx, 
loc.y+=dy); show(); }

        virtual void hide() { pw->hide(); }

        virtual void show() { pw->show(); }

        virtual void attach(Window&) = 0;



        Point loc;

        int width;

        int height;

        string label;

        Callback do_it;



        virtual ~Widget() { }



    protected:

        Window* own;    // every Widget belongs to a Window

        Fl_Widget* pw;  // connection to the FLTK Widget

    private:

        Widget& operator=(const Widget&); // don't copy Widgets

        Widget(const Widget&);

    };



//------------------------------------------------------------------------------



    struct Button : Widget {

        Button(Point xy, int w, int h, const string& label, Callback cb)

            : Widget(xy,w,h,label,cb)

        {}



        void attach(Window&);

    };



//------------------------------------------------------------------------------



    struct In_box : Widget {

        In_box(Point xy, int w, int h, const string& s)

            :Widget(xy,w,h,s,0) { }

        int get_int();

        string get_string();



        void attach(Window& win);

    };



//------------------------------------------------------------------------------



    struct Out_box : Widget {

        Out_box(Point xy, int w, int h, const string& s)

            :Widget(xy,w,h,s,0) { }

        void put(int);

        void put(const string&);



        void attach(Window& win);

    };



//------------------------------------------------------------------------------



    struct Menu : Widget {

        enum Kind { horizontal, vertical };

        Menu(Point xy, int w, int h, Kind kk, const string& label)

            : Widget(xy,w,h,label,0), k(kk), offset(0)

        {}



        Vector_ref<Button> selection;

        Kind k;

        int offset;

        int attach(Button& b);      // Menu does not delete &b

        int attach(Button* p);      // Menu deletes p



        void show()                 // show all buttons

        {

            for (unsigned int i = 0; i<selection.size(); ++i)

                selection[i].show();

        }

        void hide()                 // hide all buttons

        {

            for (unsigned int i = 0; i<selection.size(); ++i)

                selection[i].hide();

        }

        void move(int dx, int dy)   // move all buttons

        {

            for (unsigned int i = 0; i<selection.size(); ++i)

                selection[i].move(dx,dy);

        }



        void attach(Window& win)    // attach all buttons

        {

            for (int i=0; i<selection.size(); ++i) win.attach(selection[i]);

            own = &win;

        }



    };



//------------------------------------------------------------------------------



} // of namespace Graph_lib



#endif // GUI_GUARD

---------------------------------
new result of my "make"
-------------------------------------------------------------
e...@eric-laptop:~/BStrou/usingC++4/code/Chapter12$ make
make[1]: Entering directory `/home/eric/BStrou/usingC++4/code/GUI'
g++ -I"" -Wall -time -O3 -DNDEBUG -o Graph.o -c Graph.cpp
In file included from /usr/include/c++/4.4/ext/hash_map:60,
                 from std_lib_facilities.h:34,
                 from Graph.h:13,
                 from Graph.cpp:9:
/usr/include/c++/4.4/backward/backward_warning.h:28:2: warning: #warning This 
file includes at least one deprecated or antiquated header which may be removed 
without further notice at a future date. Please use a non-deprecated interface 
with equivalent functionality instead. For a listing of replacement headers and 
interfaces, consult the file backward_warning.h. To disable this warning use 
-Wno-deprecated.
# cc1plus 1.87 0.06
# as 0.03 0.00
g++ -I"" -Wall -time -O3 -DNDEBUG -o GUI.o -c GUI.cpp
In file included from /usr/include/c++/4.4/ext/hash_map:60,
                 from std_lib_facilities.h:34,
                 from Graph.h:13,
                 from GUI.h:11,
                 from GUI.cpp:10:
/usr/include/c++/4.4/backward/backward_warning.h:28:2: warning: #warning This 
file includes at least one deprecated or antiquated header which may be removed 
without further notice at a future date. Please use a non-deprecated interface 
with equivalent functionality instead. For a listing of replacement headers and 
interfaces, consult the file backward_warning.h. To disable this warning use 
-Wno-deprecated.
# cc1plus 0.74 0.04
# as 0.00 0.01
g++ -I"" -Wall -time -O3 -DNDEBUG -o Simple_window.o -c Simple_window.cpp
In file included from /usr/include/c++/4.4/ext/hash_map:60,
                 from std_lib_facilities.h:34,
                 from Graph.h:13,
                 from GUI.h:11,
                 from Simple_window.h:10,
                 from Simple_window.cpp:7:
/usr/include/c++/4.4/backward/backward_warning.h:28:2: warning: #warning This 
file includes at least one deprecated or antiquated header which may be removed 
without further notice at a future date. Please use a non-deprecated interface 
with equivalent functionality instead. For a listing of replacement headers and 
interfaces, consult the file backward_warning.h. To disable this warning use 
-Wno-deprecated.
In file included from Simple_window.cpp:7:
Simple_window.h:17: error: reference to ‘Window’ is ambiguous
/usr/include/X11/X.h:96: error: candidates are: typedef XID Window
Window.h:26: error:                 class Graph_lib::Window
Simple_window.h:17: error: reference to ‘Window’ is ambiguous
/usr/include/X11/X.h:96: error: candidates are: typedef XID Window
Window.h:26: error:                 class Graph_lib::Window
Simple_window.cpp: In constructor ‘Simple_window::Simple_window(Point, int, 
int, const String&)’:
Simple_window.cpp:12: error: reference to ‘Window’ is ambiguous
/usr/include/X11/X.h:96: error: candidates are: typedef XID Window
Window.h:26: error:                 class Graph_lib::Window
Simple_window.cpp:12: error: class ‘Simple_window’ does not have any field 
named ‘Window’
Simple_window.cpp:16: error: ‘attach’ was not declared in this scope
Simple_window.cpp: In member function ‘bool 
Simple_window::wait_for_button()’:
Simple_window.cpp:26: error: ‘show’ was not declared in this scope
Simple_window.cpp: In member function ‘void Simple_window::next()’:
Simple_window.cpp:53: error: ‘hide’ was not declared in this scope
# cc1plus 0.54 0.04
make[1]: *** [Simple_window.o] Error 1
rm Graph.o GUI.o
make[1]: Leaving directory `/home/eric/BStrou/usingC++4/code/GUI'
make: *** [../GUI/libbookgui.a] Error 2
e...@eric-laptop:~/BStrou/usingC++4/code/Chapter12$



-------------------------------------------------------------------

> -------------------------------------------------------
> and the Makefile is
> -------------
> e...@eric-laptop:~/BStrou/usingC++4/code/Chapter12$ cat Makefile
> #
> # This is a common Makefile for code examples from the book
> # "Programming -- Principles and Practice Using C++" by Bjarne Stroustrup
> #
>
> #
> # Usage:
> #     make        - Build all examples
> #     make clean  - Clean all examples
> #     make test   - Run the test suite
> #
>
> INCLUDES = -I"../GUI" -I"$(FLTK)"
> LIBS     = -lstdc++ -lbookgui -lfltk -lfltk_images
> CXXFLAGS = $(INCLUDES) -Wall -time -O3 -DNDEBUG
> LIBFLAGS = -L"../GUI"
> AR       = ar
>
> # NOTE: If under Cygwin you get an error that uname command is not found,
> #       make sure there are no folders with space in their names that preceed
> #       the path to the Cygwin's bin folder inside your PATH variable.
> ifeq ($(shell uname -o),Cygwin)
>   OS=Cygwin
> else
>   OS=$(shell uname)
> endif
>
> ifeq ($(OS),Cygwin)
>   LIBS := $(LIBS) -lfltk_jpeg -luser32 -lgdi32 -lshell32 -lole32 -luuid 
> -lWs2_32 -lComCtl32
> else
> ifeq ($(OS),Darwin)
>   LIBS := $(LIBS) -ljpeg -framework Carbon
> else
>   LIBS := $(LIBS) -lX11 -ljpeg
> endif
> endif
>
> .SUFFIXES: .cpp .o
>
> # Create a list of source files.
> SOURCES  = $(shell ls *.cpp)
> # Create a list of object files from the source file lists.
> OBJECTS = ${SOURCES:.cpp=.o}
> # Create a list of targets.
> TARGETS = ${SOURCES:.cpp=.exe}
>
> # Build all targets by default
> all:  $(TARGETS)
>
> # Files with extension .no-link.cpp are not intended for linking
> %.no-link.exe: %.no-link.o
>       @echo Linking skipped for $@
>       @echo 
> ================================================================================
>       @echo Done building $@
>       @echo 
> ================================================================================
>       @echo
>       @echo
>
> # A rule to build .exe file out of a .o file
> %.exe: %.o ../GUI/libbookgui.a
>       $(CXX) -o $@ $(LIBFLAGS) $< $(LIBS)
>       @echo 
> ================================================================================
>       @echo Done building $@
>       @echo 
> ================================================================================
>       @echo
>       @echo
>
> # A rule to build .o file out of a .cpp file
> %.o: %.cpp
>       $(CXX) $(CXXFLAGS) -o $@ -c $<
>
> # A rule to build the common GUI library
> ../GUI/libbookgui.a: ../GUI/*.h ../GUI/*.cpp
>       @(cd ../GUI; $(MAKE))
>
> # A rule to clean all the intermediates and targets
> clean:
>       rm -rf $(TARGETS) $(OBJECTS) *.out *.stackdump
>
> # A rule to run set of tests
> test:
>       @for file in *.exe; do \
>           name=`basename $$file .exe` ; \
>           name=`basename $$name .crash` ; \
>           if (ls $$name.crash.exe >/dev/null 2>&1) ; then \
>               continue ; \
>           fi ; \
>           echo ======================================== [ $$file ] ; \
>           if (ls $$name.*in >/dev/null 2>&1) ; then \
>               for f in $$name.*in; do \
>                   echo ; \
>                   echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { "$$f" } ; \
>                   cat "$$f" ; \
>                   echo ; \
>                   echo ---------------------------------------- ; \
>                   ./$$file < "$$f" ; \
>               done ; \
>           else \
>             ./$$file ; \
>           fi \
>       done ; \
>       echo -n
> e...@eric-laptop:~/BStrou/usingC++4/code/Chapter12$
> --------------------------------------------------------


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

Reply via email to