Everhart,Glenn From: hoffman@xdelta.enet.dec.nospam Sent: Monday, April 27, 1998 2:19 PM To: Info-VAX@Mvb.Saic.Com Subject: Re: VAX ALPHA C migration share problems In article <01bd6cbc$12a3fb70$0100007f@jlahman>, "Jim Lahman" writes: You've got a bit source code involved here, some of which was provided and some of which was not. You still haven't indicated what is going on here -- no specifics on the (mis)behaviour or the error messages. I ended up trying to guess what you are attempting here, and I created a new example of how to work with a common. (I'll see about getting this example posted at the website.) See below. I would *strongly* encourage you to move to global sections for this purpose. In my opinion, commons are a source of maintenance and of programming headaches, and are something I strongly prefer to avoid. For source examples of shareable images and global sections, see: http://www.partner.digital.com/www-swdev/pages/Home/TECH/faqs/ovms/ovms.html And as a suggestion, when posting requests for help, all error messages, a concise problem statement, and a fully buildable and standalone source example are highly recommended -- these simple steps will make it far more likely someone will expend the effort to answer your question(s)... Here is a standalone example that will compile and link an OpenVMS common, and that wiill compile and link an associated demonstration test program against the common: $! Fac.Com $! Copyright 1998 Digital Equipment Corporation All Rights Reserved $! Stephen Hoffman, OpenVMS Engineering, Nashua NH $ $ write sys$output "OpenVMS Alpha C COMMON Example" $ copy sys$input: faccommon.h /* // faccommon.h // Copyright 1998 Digital Equipment Corporation All Rights Reserved // This is an OpenVMS Alpha C Common example; created by fac.com... */ #define ARRAYSTEP 10 #define ARRAYSIZE 100 #pragma extern_model save #pragma extern_model common_block shr struct FacCommonStruct { int ArraySize; int Array[ARRAYSIZE]; }; extern struct FacCommonStruct FacCommon; #pragma extern_model restore $ if f$search("FacCommon.h.-1") .nes. "" then purge FacCommon.h $ cc FacCommon.h $ link/share=FacCommonWrtShr FacCommon,Sys$Input/Opt Symbol_Vector=(FacCommon=PSECT) PSECT_ATTR=FacCommon,shr $ Install Replace sys$disk:[]FacCommonWrtShr /write/head/share/open $ define/job/nolog FacCommonWrtShr sys$disk:[]FacCommonWrtShr.exe $ if f$search("FacCommon.Obj.-1") .nes. "" then purge FacCommon.Obj $ wait 00:00:02 $ if f$search("FacCommonWrtShr.Exe.-1") .nes. "" then purge FacCommonWrtShr.Exe $ $ cc sys$input/obj=facmain.obj /* // facmain.c // Copyright 1998 Digital Equipment Corporation All Rights Reserved // This is an OpenVMS Alpha C Common example; created by fac.com... */ #include #include #include #include "sys$disk:[]faccommon.h" main() { int i; printf("FacMain is running...\n"); printf("FacMain is examining the contents of the common...\n"); printf(" FacCommon.ArraySize = %d\n", FacCommon.ArraySize ); FacCommon.ArraySize = ARRAYSIZE; for ( i = 0; i < ARRAYSIZE; i++ ) if ( !(i % ARRAYSTEP) ) printf(" FacCommon.Array[%d] = %d\n", i, FacCommon.Array[i] ); printf("FacMain is updating the contents of the common...\n"); for ( i = 0; i < ARRAYSIZE; i++ ) FacCommon.Array[i] += 1; printf("FacMain is examining the contents of the common...\n"); for ( i = 0; i < ARRAYSIZE; i++ ) if ( !(i % ARRAYSTEP) ) printf(" FacCommon.Array[%d] = %d\n", i, FacCommon.Array[i] ); printf("Run again to update the common again...\n"); printf("FacMain is done...\n"); return SS$_NORMAL; } $ link facmain,Sys$Input/Option sys$disk:[]FacCommonWrtShr/share $ if f$search("FacMain.Obj.-1") .nes. "" then purge FacMain.Obj $ if f$search("FacMain.Exe.-1") .nes. "" then purge FacMain.Exe $ write sys$output "Rebuild completed. It's now time to RUN FACMAIN" $ Exit -------------------------- pure personal opinion --------------------------- Hoff (Stephen) Hoffman OpenVMS Engineering hoffman@xdelta.ZZenet.dec.com note to those folks not contributing spam -- there is no ZZ in my address