[Bug c++/29861] New: Language Related

hummrj6 at wfu dot edu gcc-bugzilla@gcc.gnu.org
Thu Nov 16 01:40:00 GMT 2006


Hi. Don't see anywhere to attach the example file, so it will be pasted in
after the brief problem description.

The compiler error output is quite terse so I've no idea what it thinks is
wrong. G++ doesn't seem to understand the difference between a member function
and the used of the global scope :: operator. The idea is to create a C++ class
to wrap up together the X Display data type along with it's associated
functions. Although I'm not a language lawyer, I've successfully used this same
approach on other platforms. 

Thanks for addressing the issue :-)
Sincerely,
Richard Hummel


below is main.cpp with G++ version and OS info
----------------------------------------------------------

/*

  --------------GCC & OS INFOMRATION ------------------------------------
[hummrj6@localhost ~]$ g++ --version
g++ (GCC) 4.1.1 20061011 (Red Hat 4.1.1-30)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

---------------------CMD LINE USED --------------------------------------
[hummrj6@localhost gerr]$ g++ main.cpp
main.cpp:66: error: expected `)' before ‘void’
main.cpp:66: error: expected `)' before ‘void’
[hummrj6@localhost gerr]$

*/

#include <X11/Xlib.h>
#include <X11/X.h>
#include <X11/Xutil.h>
#include <X11/cursorfont.h>

using namespace std;


//////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////
class RDisplay
{
    private:
    RDisplay() { /*nada */ }

    Display *m_pDisplay;
    Screen  *m_pScreen;
    int      m_iScreenNumber;

    public:

    RDisplay(char *p) {/*nada */}
    virtual ~RDisplay() {/*nada */}

    operator Display* () { return m_pDisplay; }

    // X defines int DefaultScreen(Display *display);

    /* 
        Ok, we are going to use the standard technique of wrapping
        together the data and functions together, in this case it is X stuff.

        we want to create a "wrapper class" and force the association
        between the Display and the Display functions.
        G++ errors with:
    */
    // main.cpp:66: error: expected `)' before ‘void’
    int DefaultScreen(void) { return ::DefaultScreen(m_pDisplay); }
};
//////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{   
    RDisplay r(NULL);

    return(1);
}
----------------------------------------------------------------------
                main.cpp EOF


-- 
           Summary: Language Related
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hummrj6 at wfu dot edu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29861



More information about the Gcc-bugs mailing list