C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

compile error

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
shishir
Guest





PostPosted: Thu Aug 26, 2004 3:20 pm    Post subject: compile error Reply with 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 ?
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





PostPosted: Thu Aug 26, 2004 3:27 pm    Post subject: Re: compile error Reply with quote



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





PostPosted: Thu Aug 26, 2004 4:34 pm    Post subject: Re: compile error Reply with quote



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





PostPosted: Fri Aug 27, 2004 11:06 am    Post subject: Re: compile error Reply with quote

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





PostPosted: Fri Aug 27, 2004 11:27 am    Post subject: Re: compile error Reply with quote

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





PostPosted: Fri Aug 27, 2004 11:31 am    Post subject: Re: compile error Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.