Any tips on finding the problematic line of code?

Discussion in 'C++' started by Eric Lilja, Jul 1, 2006.

  1. Eric Lilja

    Eric Lilja Guest

    Hello, when I compile my project I get this (after doing a complete
    clean first):
    $ make
    g++ -Wall -W -ansi -pedantic -g3 -O0 -D_WIN32_WINNT=0x501
    -D_WIN32_IE=0x600 -c common_dialogs.cpp
    g++ -Wall -W -ansi -pedantic -g3 -O0 -D_WIN32_WINNT=0x501
    -D_WIN32_IE=0x600 -c crc32.cpp
    g++ -Wall -W -ansi -pedantic -g3 -O0 -D_WIN32_WINNT=0x501
    -D_WIN32_IE=0x600 -c globals.cpp
    g++ -Wall -W -ansi -pedantic -g3 -O0 -D_WIN32_WINNT=0x501
    -D_WIN32_IE=0x600 -c main_window_procedure.cpp
    g++ -Wall -W -ansi -pedantic -g3 -O0 -D_WIN32_WINNT=0x501
    -D_WIN32_IE=0x600 -c sfv_list_view.cpp
    In file included from
    /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/sstream:640,
    from sfv_list_view.cpp:8:
    /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/sstream.tcc: In
    member function `virtual typename std::basic_stringbuf<_CharT, _Traits,
    _Alloc>::int_type std::basic_stringbuf<_CharT, _Traits,
    _Alloc>::eek:verflow(typename _Traits::int_type)':
    /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/sstream.tcc:102:
    error: expected unqualified-id before '(' token
    /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/sstream.tcc:104:
    error: expected unqualified-id before '(' token
    sfv_list_view.cpp: At global scope:
    sfv_list_view.cpp:184: warning: unused parameter 'arg'
    make: *** [sfv_list_view.o] Error 1

    It seems to be a problem involving how stringstreams are used in
    sfv_list_view.cpp but all error messages point to the implementation
    files of the standard library. Any tips on finding the offending line
    of code that triggers all these obscure error messages deep inside
    libstdc++ other than commenting things out (which may or may not be
    easy to do)?

    / E
     
    Eric Lilja, Jul 1, 2006
    #1
    1. Advertising

  2. Eric Lilja

    Eric Lilja Guest

    Eric Lilja wrote:
    > Hello, when I compile my project I get this (after doing a complete
    > clean first):
    > $ make
    > g++ -Wall -W -ansi -pedantic -g3 -O0 -D_WIN32_WINNT=0x501
    > -D_WIN32_IE=0x600 -c common_dialogs.cpp
    > g++ -Wall -W -ansi -pedantic -g3 -O0 -D_WIN32_WINNT=0x501
    > -D_WIN32_IE=0x600 -c crc32.cpp
    > g++ -Wall -W -ansi -pedantic -g3 -O0 -D_WIN32_WINNT=0x501
    > -D_WIN32_IE=0x600 -c globals.cpp
    > g++ -Wall -W -ansi -pedantic -g3 -O0 -D_WIN32_WINNT=0x501
    > -D_WIN32_IE=0x600 -c main_window_procedure.cpp
    > g++ -Wall -W -ansi -pedantic -g3 -O0 -D_WIN32_WINNT=0x501
    > -D_WIN32_IE=0x600 -c sfv_list_view.cpp
    > In file included from
    > /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/sstream:640,
    > from sfv_list_view.cpp:8:
    > /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/sstream.tcc: In
    > member function `virtual typename std::basic_stringbuf<_CharT, _Traits,
    > _Alloc>::int_type std::basic_stringbuf<_CharT, _Traits,
    > _Alloc>::eek:verflow(typename _Traits::int_type)':
    > /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/sstream.tcc:102:
    > error: expected unqualified-id before '(' token
    > /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/sstream.tcc:104:
    > error: expected unqualified-id before '(' token
    > sfv_list_view.cpp: At global scope:
    > sfv_list_view.cpp:184: warning: unused parameter 'arg'
    > make: *** [sfv_list_view.o] Error 1
    >
    > It seems to be a problem involving how stringstreams are used in
    > sfv_list_view.cpp but all error messages point to the implementation
    > files of the standard library. Any tips on finding the offending line
    > of code that triggers all these obscure error messages deep inside
    > libstdc++ other than commenting things out (which may or may not be
    > easy to do)?
    >
    > / E


    Ok, this particular problem was caused by include order...
     
    Eric Lilja, Jul 1, 2006
    #2
    1. Advertising

  3. Eric Lilja

    Phlip Guest

    Eric Lilja wrote:

    > /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/sstream.tcc:102:
    > error: expected unqualified-id before '(' token


    Next time, look that line up and paste it into this post.

    The line contains std::max(

    Some systems also define max as a macro.

    Go to sfv_list_view.cpp:7:, above the #include <sstream>, and add this:

    #undef max

    That's just a guess, so report back if it doesn't work.

    --
    Phlip
    http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
     
    Phlip, Jul 1, 2006
    #3
  4. Eric Lilja

    kwikius Guest

    Phlip wrote:
    > Eric Lilja wrote:
    >
    > > /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/sstream.tcc:102:
    > > error: expected unqualified-id before '(' token

    >
    > Next time, look that line up and paste it into this post.
    >
    > The line contains std::max(
    >
    > Some systems also define max as a macro.
    >
    > Go to sfv_list_view.cpp:7:, above the #include <sstream>, and add this:
    >
    > #undef max
    >
    > That's just a guess, so report back if it doesn't work.


    FWIW the *acceptable* way to deal with this situation (courtesy of the
    gurus at http://www.boost.org) is as follows:

    // crappy hackers macro
    #define min(a,b) (((a) < (b)) ? (a) : (b))

    struct my{
    typedef int min;
    };

    int main()
    {
    //###################################
    // int n = my::min(); // Error
    //###################################
    #define PREVENT_MACRO_SUBSTITUTION
    int n = my::min PREVENT_MACRO_SUBSTITUTION (); // OK
    }

    The boost version in <boost/config.hpp> is called
    BOOST_PREVENT_MACRO_SUBSTITUTION and is worth using so the gurus
    understand what you mean when they read your code.

    regards
    Andy Little
     
    kwikius, Jul 1, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lim Siew Cheng

    Re: Problematic Postbacks

    Lim Siew Cheng, Aug 12, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    378
    IbrahimMalluf
    Aug 12, 2003
  2. Duray AKAR

    Problematic Postbacks

    Duray AKAR, Aug 12, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    336
    Duray AKAR
    Aug 12, 2003
  3. Gregor H.

    Problematic code in K&R

    Gregor H., Apr 19, 2007, in forum: C Programming
    Replies:
    1
    Views:
    299
    Gregor H.
    Apr 19, 2007
  4. PerlNovice

    Problematic Perl code

    PerlNovice, Jan 2, 2007, in forum: Perl Misc
    Replies:
    8
    Views:
    114
    Eric Schwartz
    Jan 5, 2007
  5. Replies:
    1
    Views:
    3,166
    Arne Vajhøj
    Jul 31, 2012
Loading...

Share This Page