delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/20/10:27:36

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: 'volatile' undeclared from here
Date: 20 Apr 2000 13:30:43 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 56
Message-ID: <8dn0q3$dvv$1@nets3.rz.RWTH-Aachen.DE>
References: <fAeL4.1879$_d1 DOT 3770486 AT nnrp4 DOT proxad DOT net> <8dk3aa$m6a$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <9LgL4.1906$D21 DOT 3649551 AT nnrp4 DOT proxad DOT net> <8dkfaj$rk1$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <XljL4.1955$C91 DOT 3755056 AT nnrp4 DOT proxad DOT net> <8dkh60$sjr$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <ktyL4.2008$hy DOT 2487363 AT nnrp6 DOT proxad DOT net> <8dml61$9co$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <zZBL4.2058$k32 DOT 3019817 AT nnrp6 DOT proxad DOT net>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 956237443 14335 137.226.32.75 (20 Apr 2000 13:30:43 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 20 Apr 2000 13:30:43 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Alexandre Devaure <Alexandre DOT Devaure AT leroy-autom DOT com> wrote:
[...]
> here is the output of gcc -E :

OK, thanks. I've confronted Linux/ix86 gcc-2.95.2 with that source file, and
indeed, it throws the error message you reported:

[oahu] /tmp $ gcc -c -O2 cppasm.ii      
tst.cpp: In method `int TValueFifo<bidon,2>::PutSecure(const bidon &)':
tst.cpp:63:   instantiated from here
tst.cpp:48: `volatile' undeclared (first use this function)
tst.cpp:48: (Each undeclared identifier is reported only once
tst.cpp:48: for each function it appears in.)
tst.cpp:48: warning:  qualifier ignored on asm

So I looked into the documentation of gcc-2.95.2, a bit, and I think I
found a possible reason for that problem: the effect of 'volatile' in
an inline asm statement only is for *extended* inline asm. Yours is an
'old style' one, as it does not specify any input/output/clobber
lists. For such assembly blocks the gcc-2.95.2 docs say:

--- quote ---
   An `asm' instruction without any operands or clobbers (and "old
style" `asm') will not be deleted or moved significantly, regardless,
unless it is unreachable, the same wasy as if you had written a
`volatile' keyword.
--- end quote ---

In other words: you don't need the volatile keyword, here, and that's
why it is being 'ignored', as the 'qualifier ignored' warning message
from gcc correctly points out.

So the question remains: why that "`volatile' undeclared" error
message, in addition to it? And why only if it's compiled as C++?  I'm
not altogether certain this constitutes a bug in gcc, but it may be
interpreted as one. OTOH, nowhere in the manual do I find a statement
that inline is supposed to work in C++ programs *at all*. Strictly
interpreting the docs, extended inline asm is a C language extension,
but not necessarily valid in C++.

In C++, 'asm' seems to be defined as an ANSI/ISO standardized reserved
word of the language. This may also imply a certain set of semantics
which disallow use of 'volatile' in non-extended asm blocks.

Summing it all up: you can work around the problem by simply
*removing* the volatile keyword, I think. Its desired effect is
granted anyway, no matter if it's written out or not, in your case.

[...]
>         int PutSecure(const bidon& Value)
>         {
>                 __asm__ __volatile__("pushf");

-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019