Any tips on finding the problematic line of code?

E

Eric Lilja

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
 
E

Eric Lilja

Eric said:
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...
 
P

Phlip

Eric said:
/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.
 
K

kwikius

Phlip said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,744
Latest member
CortneyMcK

Latest Threads

Top