From: SMTP%"smithdm@wmvx.lvs.dupont.com" 20-APR-1994 11:18:01.92 To: EVERHART CC: Subj: Re: Problems with VAX C tools ported to DEC C? X-Newsgroups: comp.os.vms From: smithdm@wmvx.lvs.dupont.com (David M. Smith) Subject: Re: Problems with VAX C tools ported to DEC C? Message-ID: <1994Apr19.190457.16395@es.dupont.com> Sender: news@es.dupont.com (USENET News System) Nntp-Posting-Host: ldoc03.lvs.dupont.com Reply-To: smithdm@wmvx.lvs.dupont.com Organization: DuPont (Opinions are those of the writer only) Date: Tue, 19 Apr 1994 19:04:57 GMT Lines: 42 To: Info-VAX@CRVAX.SRI.COM X-Gateway-Source-Info: USENET In article <1994Apr18.171403.2864@objy.com>, bruce@objy.com (Bruce Reed) writes: >I'm looking for feedback from other users who have seen strange behavior >from VAX C VAX/VMS compiled tools that were ported to Open/VMS AXP with >DEC C. The few tools I've ported compiled rather easily using the >/STANDARD=VAXC mode of DEC C, but they just don't run right. In the past two weeks I have moved two .C programs from VAX to Alpha. I encountered a number of minor problems which showed up as compile-time errors. These were fairly easy to fix. The most difficult problem I encountered was in one of the programs after it compiled correctly it didn't work correctly. I had not written the original program, so it took a fairly lengthy debugging session to understand what was going on. The general problem I had was the difference in VAX C and DEC C on Alpha with regard to the default for #pragma member_alignment. You can look this up in the books, but the gist of it is that structures and/or unions compiled under VAX C may have a different layout in when compiled on Alpha under DEC C, due to DEC C "lining up" new elements of the structure on "natural" boundaries. This might be O.K. in general, but isn't if the structure happens to describe a pre-existing disk file as it did in my case. The program was accessing the wrong bytes from records and producing bizarre results. After seeing what was going on, I added code similar to the following to several include files which define record layouts: #pragma nostandard #pragma member_alignment __save #pragma nomember_alignment . . (original definitions here) . #pragma standard #pragma member_alignment __restore I found this sequence of preprocessor directives in some of the include modules in ALPHA$LIBRARY:SYS$STARLET_C.TLB. -------------------------------------------------------------------------------- David M. Smith (302) 774-6914 smithdm@wmvx.dnet.dupont.com DuPont (Opinions are those of the writer only) --------------------------------------------------------------------------------