| View previous topic :: View next topic |
| Author |
Message |
shishir Guest
|
Posted: Thu Aug 26, 2004 3:20 pm Post subject: compile error |
|
|
hi
the following may be offtopic.
gcc 3.3.3 compiler throws error like
.....: error: invalid in-class
initialization of static data member of non-integral type `const
char[]'
...... error: looser throw specifier for virtual void X::y()
etc
for the same source gcc 2.95.2 doesn't throw any error. What could be
the reason ?
1 more thing...-fno-rtti doesn't have any affect on gcc 3.3.3. In both
the cases -frtti and -fno-rtti, code generated are same.
did i miss any patch or what is the recent gcc version which works ?
Thanks
|
|
| Back to top |
|
 |
Victor Bazarov Guest
|
Posted: Thu Aug 26, 2004 3:27 pm Post subject: Re: compile error |
|
|
shishir wrote:
| Quote: | the following may be offtopic.
gcc 3.3.3 compiler throws error like
....: error: invalid in-class
initialization of static data member of non-integral type `const
char[]'
..... error: looser throw specifier for virtual void X::y()
etc
for the same source gcc 2.95.2 doesn't throw any error. What could be
the reason ?
|
I know of one reason: 3.3.3 is more Standard-compliant than 2.95.2.
| Quote: | 1 more thing...-fno-rtti doesn't have any affect on gcc 3.3.3. In both
the cases -frtti and -fno-rtti, code generated are same.
did i miss any patch or what is the recent gcc version which works ?
|
Ask in gnu.gcc.help. Adding or not adding RTTI has no effect if your
code doesn't use RTTI (typeid operator and so on)
Victor
|
|
| Back to top |
|
 |
Rolf Magnus Guest
|
Posted: Thu Aug 26, 2004 4:34 pm Post subject: Re: compile error |
|
|
shishir wrote:
| Quote: | hi
the following may be offtopic.
gcc 3.3.3 compiler throws error like
....: error: invalid in-class
initialization of static data member of non-integral type `const
char[]'
..... error: looser throw specifier for virtual void X::y()
etc
for the same source gcc 2.95.2 doesn't throw any error. What could be
the reason ?
|
Maybe just because you did the things it's complaining about. Newer
versions of gcc are much more standard compliant than older ones,
resulting in more errors if your code is invalid.
| Quote: | 1 more thing...-fno-rtti doesn't have any affect on gcc 3.3.3. In both
the cases -frtti and -fno-rtti, code generated are same.
|
Are you actually using any rtti in your code?
| Quote: | did i miss any patch or what is the recent gcc version which works ?
|
They should all work well.
|
|
| Back to top |
|
 |
shishir Guest
|
Posted: Fri Aug 27, 2004 11:06 am Post subject: Re: compile error |
|
|
| Quote: | Are you actually using any rtti in your code?
int main() |
{
try
{
throw new int()
}
catch (...)
{
printf("nCaught");
}
}
the above piece of code produces the same object code with -frrti and
-fno-rtti option.
| Quote: | They should all work well.
Also, gcc fails to link c++ object codes, it is the g++ which is able |
to link.
|
|
| Back to top |
|
 |
Rolf Magnus Guest
|
Posted: Fri Aug 27, 2004 11:27 am Post subject: Re: compile error |
|
|
shishir wrote:
| Quote: | Are you actually using any rtti in your code?
int main()
{
try
{
throw new int()
}
catch (...)
{
printf("nCaught");
}
}
the above piece of code produces the same object code with -frrti and
-fno-rtti option.
|
That's because it doesn't use RTTI. You seem to be confusing exceptions
with RTTI.
Try this instead:
#include <iostream>
struct A { virtual ~A() {} };
struct B: public A {};
int main()
{
A* a = new B();
std::cout << typeid(a).name() << std::endl;
delete a;
}
| Quote: | They should all work well.
Also, gcc fails to link c++ object codes, it is the g++ which is able
to link.
|
Yes. That's intended. gcc won't link in the C++ standard library.
|
|
| Back to top |
|
 |
Rolf Magnus Guest
|
Posted: Fri Aug 27, 2004 11:31 am Post subject: Re: compile error |
|
|
Rolf Magnus wrote:
| Quote: | shishir wrote:
Are you actually using any rtti in your code?
int main()
{
try
{
throw new int()
}
catch (...)
{
printf("nCaught");
}
}
the above piece of code produces the same object code with -frrti and
-fno-rtti option.
That's because it doesn't use RTTI. You seem to be confusing
exceptions with RTTI.
Try this instead:
#include
struct A { virtual ~A() {} };
struct B: public A {};
int main()
{
A* a = new B();
std::cout << typeid(a).name() << std::endl;
|
Oops. Of course, it would have to be:
std::cout << typeid(*a).name() << std::endl;
| Quote: | delete a;
}
They should all work well.
Also, gcc fails to link c++ object codes, it is the g++ which is able
to link.
Yes. That's intended. gcc won't link in the C++ standard library.
|
|
|
| Back to top |
|
 |
|