problem with int_type....

S

SpreadTooThin

My compiler seems unhappy with int_type

The method declaration is:

int_type dbgBuf::eek:verflow(int_type ch)
{
#ifdef FF_DEBUG

if (traits_type::not_eof(ch))
{
if (at_start)
{
for (int i = 0; i < level; ++i)
{
if (log_on)
{
buffer->sputc(traits_type::to_char_type('\t'));
}
}
}

if (log_on)
buffer->sputc(traits_type::to_char_type(ch));

if (traits_type::eq_int_type(ch, traits_type::to_int_type('\n')))
{
at_start = true;
}
else
{
at_start = false;
}
}
#endif
return ch;
}


The error I'm getting is:

error: 'int_type' does not name a type.

So I tried:
traits_type::int_type dbgBuf::eek:verflow(traits_type::int_type ch)

and I get:
error 'traits_type' has not been declared
error: 'int_type' has does not name a type

NOTE:
None of the other 'traits_type' like to_char_type or to_int_type seem
to be affected...
or maybe they just haven't been complied yet....


Is there perhaps a header file I'm forgetting to include?


MAC OS X. 10.4
XCode
 
V

Victor Bazarov

SpreadTooThin said:
My compiler seems unhappy with int_type

There is no "int_type" (by itself) in the C++ language.
The method declaration is:

int_type dbgBuf::eek:verflow(int_type ch)
{
#ifdef FF_DEBUG

if (traits_type::not_eof(ch))

What's "traits_type"?
{
if (at_start)
{
for (int i = 0; i < level; ++i)
{
if (log_on)
{
buffer->sputc(traits_type::to_char_type('\t'));
}
}
}

if (log_on)
buffer->sputc(traits_type::to_char_type(ch));

if (traits_type::eq_int_type(ch, traits_type::to_int_type('\n')))
{
at_start = true;
}
else
{
at_start = false;
}
}
#endif
return ch;
}


The error I'm getting is:

error: 'int_type' does not name a type.

It probably doesn't.
So I tried:
traits_type::int_type dbgBuf::eek:verflow(traits_type::int_type ch)

and I get:
error 'traits_type' has not been declared

It probably wasn't.
error: 'int_type' has does not name a type

NOTE:
None of the other 'traits_type' like to_char_type or to_int_type seem
to be affected...

The compiler reported the very first occurrence of 'traits_type' as
unknown. Just for laughs, replace the return value type with 'bool'
and see if you get any further.
or maybe they just haven't been complied yet....

Quite possible.
Is there perhaps a header file I'm forgetting to include?

Perhaps. How the hell should we know. Read the FAQ 5.8.

V
 
T

Thomas J. Gritzan

SpreadTooThin said:
My compiler seems unhappy with int_type

The method declaration is:

int_type dbgBuf::eek:verflow(int_type ch)
{
#ifdef FF_DEBUG

if (traits_type::not_eof(ch))

We need the class definitions of dbgBuf and traits_type etc. to be able to
help you.

But just a guess: Try replacing int_type in the first line by
dbgBuf::traits_type::int_type.
 
J

James Kanze

There is no "int_type" (by itself) in the C++ language.

Yes, but...

This looks awfully like he's writing a streambuf. If so, dbgBuf
should inherit from std::streambuf, and there is a type int_type
declared in std::streambuf, which the compiler should find here.

There are, of course, any number of things which could be going
wrong. All of which precede the code he's posted, so we can
only guess. Two quick guesses, however: dbgBuf doesn't inherit
from std::streambuf (or std::basic_streambuf<char>), or he's
including an older version of iostreams (i.e. <iostream.h>,
rather than <iostream>). If dbgBuf does derive from
std::streambuf, he should verify that he is actually including
<streambuf>, and not <iostream.h> (or <iostream>---some older
implementations stupidly allowed you to drop the .h, while still
giving you a classical iostream, rather than the standard one).

What I don't understand here, of course, is why he's confusing
the issue by using int_type to begin with. Unless dbgBuf is a
template, he knows the actual types, and it's just a lot clearer
to use them. (And I would avoid making dbgBuf a template unless
it were absolutely necessary.)
 
J

James Kanze

[...]
Just a correction to my previous posting: if dbgBuf derives from
std::streambuf, the compiler should find
std::streambuf::int_type in the parameter declaration. For the
return type, the compiler doesn't yet know that it is processing
a member function of a class derived from std::streambuf, and so
will not find it. A scope qualifier is necessary:

dbgBuf::int_type dbgBuf::eek:verflow( int_type ch )
 

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

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,234
Latest member
SkyeWeems

Latest Threads

Top