TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Robin Sheppard
from: George White
date: 1998-10-01 06:42:00
subject: const/volatile

Hi Robin,

You wrote to Tom Torfs:

RS> > const volatile int foo;
RS> >
RS> > Which means the program itself may not modify foo, but some sort of
RS> > background process (e.g. an interrupt) may change the value behind our
RS> > back.

RS> JR> Hmm. I'll take your word for it, but such a statement does seem
RS> JR> contradictory to me. I'll see if it works on my compiler.

RS>   Methinks such a variable would also need to be declared extern, so
RS>   that it would be in scope for the said background (or other)
RS>   process.  Am I right here?

No, "extern" says to the compiler that the variable memory allocation is
in another module, and the linker will provide a location for it, to
make a variable available outside the module it is declared in it has
to be "public" and all C global variables are "public"
by default.

In common applications where variables that are "const volatile" are
used the two programs don't really know about the use of the locations,
they are absolute memory locations (in fact in my code the common area
is a complicated struct accessed via the "->" operator, all I have to
set up is the base address of the struct).

George

 * SLMR 2.1a * Computers eliminate spare time.

--- Maximus/2 3.01
* Origin: DoNoR/2,Woking UK (44-1483-717904) (2:440/4)
SEEN-BY: 396/1 632/0 371 633/260 267 270 371 634/397 635/506 728 810 639/252
SEEN-BY: 670/218
@PATH: 440/4 255/1 251/25 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.