[comp.lang.c] Common areas/common data/data sharing

gceych@juliet.caltech.edu (Eychaner, Glenn C.) (12/13/90)

I'm not sure that this is the right place to post this, but...
I want to get the effect of FORTRAN group common blocks in C.  In other words,
I want to be able to have 3 or 4 programs all sharing the same block of data,
some reading from it and some writing to it, without storing it all to a file
(file access is rather slow).  In FORTRAN, I would create a common block and
INSTALL it using the VAX Installer.  when I try to INSTALL a variable list
(linked shared) as a shareable image, it fails with:  cannot create writable
section to read only file.  Any ideas from anyone out there?

An example:
	I want some programs to share some data...say the variables i,j,k.
	So i create a program:
	/* Common block */
	int i,j,k;

	compile it, and link it /SHARED.  In each program I want to use it, I
	declare the variables as extern and link the program with the block.
	This allows the programs to share the variables.

	Now, to get them to share the DATA, I INSTALL it.  This fails as
	described above.

Thanks in advance for any suggestions you might have.

Glenn Eychaner   |Eychaner@SunCub.Caltech.edu|Remember: It is easier to ride a
40386 N Shore Ln |gceych@iago.caltech.edu    |camel through the eye of a needle
Big Bear City, CA|                           |than to drive a Buick through the
            92314|!*** G O   N I N E R S ***!|hole in a doughnut.

henry@zoo.toronto.edu (Henry Spencer) (12/13/90)

In article <1990Dec13.014044.9258@nntp-server.caltech.edu> gceych@juliet.caltech.edu writes:
>I want to get the effect of FORTRAN group common blocks in C.  In other words,
>I want to be able to have 3 or 4 programs all sharing the same block of data,
>some reading from it and some writing to it, without storing it all to a file
>(file access is rather slow).  In FORTRAN, I would create a common block and
>INSTALL it using the VAX Installer...

You would be better off asking this question in one of the VMS groups; I
assume it's VMS Fortran you're talking about.  The answer is very
system-specific, because such a facility is not a standard part of C
(or of Fortran, for that matter).
-- 
"The average pointer, statistically,    |Henry Spencer at U of Toronto Zoology
points somewhere in X." -Hugh Redelmeier| henry@zoo.toronto.edu   utzoo!henry