Mail Archives: djgpp/2000/04/20/10:27:36
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 -