VC++ 7.1 RTTI bug from IDE?

B

Beman Dawes

This little program:

#include <iostream>
int main()
{
#ifdef _CPPRTTI
std::cout << "_CPPRTTI is defined as " << _CPPRTTI << "\n";
#else
std::cout << "_CPPRTTI is not defined\n";
#endif
return 0;
}

Works as expected when compiled from the command line. /GR determines
which version of the code is selected.

From the IDE (7.1 retail product), the output is always "_CPPRTTI is
not defined", regardless of the setting of the Property | C/C++ |
Language | Enable Run-Time Type Info.

Looking at the Property | C/C++ | Command Line | All Options: I can
see that /GR is shown, but appears to have no effect. If /GR is added
via the Additional Options, the program then outputs "_CPPRTTI is
defined as 1".

Is this a known bug?

--Beman
 
B

Beman Dawes

David Lowndes said:
Setting "Enable Run-Time Type Info" in the IDE for a console
application defines that symbol ok for me with your sample - without
having to explicitly enter it into the command line additional options
setting.

It figures that such an obvious problem would have been detected long
ago if it always happened. And in fact, if I start a totally new
solution, add a totally new project, enter the .cpp file as a totally
new file, set the properties per above, then there is no sign of the
error.

Yet if I go back to the original solution, the error is still very
much in evidence. No amount of turning "Enable Run-Time Type Info" on
or off has any effect. (I tried at both the project and file level.)

It gets even weirder. The error happens in both debug and release
mode, but for the Microsoft compiler only. Switch to the Inter
compiler (VC++ and Intel C++ are the two installed products), and
everything works correctly. Back to the Microsoft compiler, and the
problem is still there.

Any ideas?

--Beman Dawes
 
C

Carl Daniel [VC++ MVP]

Beman said:
It gets even weirder. The error happens in both debug and release
mode, but for the Microsoft compiler only. Switch to the Intel
compiler (VC++ and Intel C++ are the two installed products), and
everything works correctly. Back to the Microsoft compiler, and the
problem is still there.

Any ideas?

That is wierd.

What's the complete set of command line arguments that the IDE is passing to
the compiler? (These are visible in BuildLog.htm - look there rather than
in the IDE dialogs to be sure).

-cd
 
B

Beman Dawes

Carl Daniel said:
What's the complete set of command line arguments that the IDE is passing to
the compiler? (These are visible in BuildLog.htm - look there rather than
in the IDE dialogs to be sure).

BuildLog.htm reports:

/Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Gm /EHsc /RTC1
/MLd /Zc:forScope /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /c /Wp64 /ZI /TP
"\sq\build\sq-vc7.1\GX_GR.cpp"

Property Pages | C/C++ | Command Line reports:

/c /ZI /nologo /W3 /Wp64 /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D
"_MBCS" /Gm /EHsc /RTC1 /MLd /Zc:forScope /GR /Fo"Debug/"
/Fd"Debug/vc70.pdb" /Gd /TP

Note /GR in the latter, but not in the former. This is consistent with
the observed behavior of the resulting program; the compiler (cl.exe)
gets it right. The fault seems to be that the IDE is not passing /GR
to the compiler.

--Beman
 
C

Carl Daniel [VC++ MVP]

Beman said:
BuildLog.htm reports:

/Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Gm /EHsc /RTC1
/MLd /Zc:forScope /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /c /Wp64 /ZI /TP
"\sq\build\sq-vc7.1\GX_GR.cpp"

Property Pages | C/C++ | Command Line reports:

/c /ZI /nologo /W3 /Wp64 /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D
"_MBCS" /Gm /EHsc /RTC1 /MLd /Zc:forScope /GR /Fo"Debug/"
/Fd"Debug/vc70.pdb" /Gd /TP

Note /GR in the latter, but not in the former. This is consistent with
the observed behavior of the resulting program; the compiler (cl.exe)
gets it right. The fault seems to be that the IDE is not passing /GR
to the compiler.

Yep. Seems there's a problem with the build system in the IDE. I'll make
sure someone from the VC team noticies this thread - would you be able to
post the .vcproj file? If it's confidential, I'm sure someone from the team
would take it by email if you're unable/unwilling to post it.

-cd
 
B

Beman Dawes

Carl Daniel said:
Yep. Seems there's a problem with the build system in the IDE. I'll make
sure someone from the VC team noticies this thread - would you be able to
post the .vcproj file? If it's confidential, I'm sure someone from the team
would take it by email if you're unable/unwilling to post it.

I'm bailing out for a few days of vacation. I'll try to get something
together when I get back.

Thanks,

--Beman
 
A

Andrew Burlak

I bet you imported the project from MSVC 6, and, in original project, you
didn't have RTTI enabled.

When imported from VC6, most settings are explicitly set on individual
files, and not inherited from the project.
So if you then change settings at the project level, they have no effect.

These are (open Properties for any individual .cpp file, and _not_ for the
project):

- Include Directories (C/C++/General/Additional Include Directories, notice
the ($NoInherit) string)
- Preprocessor definitions (C/C++/Preprocessor Definitions, notice the
($NoInherit) string)
- and a lot of other settings, including 'Enable Run-time Type Info'
(notice that some settings are shown in bold - it means that the
corresponding project-level setting has no effect for that file).
 

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

Top