* gcc/g++ equivalent for BC++ #pragma warn -xxx
@ 2001-01-24 10:23 Günter NeiÃ
2001-01-24 11:27 ` Alexandre Oliva
0 siblings, 1 reply; 2+ messages in thread
From: Günter Neià@ 2001-01-24 10:23 UTC (permalink / raw)
To: help-gcc
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1579 bytes --]
Hi,
I try to wrote all of my prg's such way, that there is no error/warning
from the compiler.
I swich all warnings on.
I thing: most of the cases a warning leads to some errors I made,
only some are just the thing I wan't.
Most of the time I am able to modify my code to supress the warning for
that cases.
But I found no way to supress the warning:
------ taking address of temporary --------
Because this is just what I mean, I look for something to supress this
message, but only for the line of code it happens (meaning that the same
problem my exist at other places in my code and there it isn't what I
like to do).
Using other compilers (e.g. BC++) I use
#pragma warn -xxx
xxx stands for the warning I like to suppress.
Is there a way to do that with gcc ??
Some more info's on that:
Version of G++ I use: 2.95.2 (Linux/pentium)
gcc options used: at least -Wall
Some code-fragment that exhibits the warning:
class Foo
{
.. // two dots (..) mean some code left off
};
void bar( Foo * pobj, ... ) // three dots (...) mean the elipse
(optional parameters)
{
// bar should process a list of Foo-objects, that's why i can't use
'Foo & obj'
va_arg ..
..
}
.. main ..
{
bar( &Foo(), NULL ); // this line gives the warning
}
As You see the above statement
bar( &Foo(), NULL );
creates a temporary object of class Foo, it's address was taken and
supplied to the function bar.
In most circumstances that isn't what someone migth, but it's right what
I need in this situation.
Thanks & greetings
Günter
Kryptographische Unterschrift mit S/MIME
[-- Attachment #2: smime.p7s --]
[-- Type: application/octet-stream, Size: 3748 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: gcc/g++ equivalent for BC++ #pragma warn -xxx
2001-01-24 10:23 gcc/g++ equivalent for BC++ #pragma warn -xxx Günter NeiÃ
@ 2001-01-24 11:27 ` Alexandre Oliva
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2001-01-24 11:27 UTC (permalink / raw)
To: Günter NeiÃÂ; +Cc: help-gcc
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 802 bytes --]
On Jan 24, 2001, Günter Neià <gneiss@schoenhofer.de> wrote:
> Most of the time I am able to modify my code to supress the warning for
> that cases.
> But I found no way to supress the warning:
> ------ taking address of temporary --------
That's because you're relying on a feature that's not supported by the
C++ standard. You can't take the address of a temporary.
The Standard-compliant work-around is to define a member function that
returns `this', and call that member function on the temporary.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-01-24 11:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-24 10:23 gcc/g++ equivalent for BC++ #pragma warn -xxx Günter NeiÃ
2001-01-24 11:27 ` Alexandre Oliva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).