gcc error: extra qualification
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: gcc error: extra qualification

  1. #1
    Join Date
    Jan 2009
    Location
    new york,usa
    Posts
    49

    gcc error: extra qualification

    i got the following when trying to compile a header file:
    Code:
    cube512.h:12: error: extra qualification 'cube512::' on member 'cube512'
    now i know this is default with gcc4.1 and up. my question is there a compiler switch to suppress this? thanks.

    t.

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,250

    Re: gcc error: extra qualification

    Show the smallest and simplest program that demonstrates the error.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Jan 2009
    Location
    new york,usa
    Posts
    49

    Re: gcc error: extra qualification

    Code:
    #ifndef BLOCK_H
    #define BLOCK_H
    
    class block{
        public:
              block::block(){
              }
    };
    #endif
    and...

    Code:
    #include<iostream>
    #include"block.h"
    using namespace std;
    
    int main(){
           block b = new block();
           cout << b << endl;
    }

  4. #4
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,250

    Re: gcc error: extra qualification

    Both of them are simply errors. You should not qualify the member name in the member declaration, and new block() returns a block*, not a block. (You also forgot to use delete.)
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  5. #5
    Join Date
    Jan 2009
    Location
    new york,usa
    Posts
    49

    Re: gcc error: extra qualification

    so there is no way around losing the "::"?

  6. #6
    Join Date
    Apr 1999
    Posts
    27,423

    Re: gcc error: extra qualification

    Quote Originally Posted by tzadik View Post
    so there is no way around losing the "::"?
    C++ has language rules. Why are you trying to do something that's against the rules of the language? Fix the erroneous code, as laserlight has already pointed out.

    Regards,

    Paul McKenzie

  7. #7
    Join Date
    May 2001
    Location
    Germany
    Posts
    1,108

    Re: gcc error: extra qualification

    The problem is that gcc 3.x accepted this, and if you have legacy code, with gcc 4.x your problems begin. I had a similar problem lately. But I know of no flag to suppress this behaviour.

  8. #8
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,250

    Re: gcc error: extra qualification

    Quote Originally Posted by Richard.J
    The problem is that gcc 3.x accepted this, and if you have legacy code, with gcc 4.x your problems begin.
    That is why I try to compile with -Wall and -pedantic flags
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center