Problems with GCC and/or VAX LINK

DAVID NEWALL ccdn at levels.sait.edu.au
Thu Mar 9 00:44:41 AEST 1989


I recently tried compiling the VAX LZCMP compression program on our
VAX.  The VAX is running VMS 5.0 and the C compiler is GNU C (don't
know what version).  I encountered a few problems:

1.  GCC doesn't allow mismatched quotation marks.  For example:
        /* this isn't going to work */
    doesn't compile because the comment has a single quotation mark.
    Interestingly, the following does compile:
        /* this is going to work, even though the quotes (')
           aren't matched on the _same_ line */
    I think this behaviour is poor -- quotes shouldn't need to be
    matched in comments.  Neither should they need matching in code
    that is #ifdef'd out.

    I've seen arguments over this behaviour before (some people claim
    it is the one true way; others disagree).  For the record, I think
    that comments are just that:  comments.  And so it shouldn't matter
    how many quotation marks they contain.  Code which is #ifdef'd out
    should be treated similarly.  I'd like this problem fixed.  (Please).

2.  The LZCMP program includes a DCL command table, which is generated
    by the VMS command "$ SET COMMAND/OBJECT".  This command table is
    linked with the C program, and referenced (in the program) via a
    "globalref" variable; the declaration looks like this:
        globalref dcl_table;    /* this is the DCL command table */
    I assumed that "globalref" meant the same as "extern".  This turns
    out not to be the case.  It seems that VMS has a "global" class for
    symbols, and that extern variables aren't "global".  It also turns
    out that extern functions _are_ global -- what I am saying is that
    "extern dcl_table" didn't work (dcl_table didn't point to the right
    place), but "extern dcl_table()" did!

    How do I reference (VAX) global symbols from a C program, assuming
    I want to compile with GCC?

3.  My investigations into "globalref" high-lighted a problem with either
    the VMS linker, or with both GCC and VAX C.  Essentialy, I can compile,
    link and execute the following program:
        extern v1;
        int v2;
        main() {
                printf("&v1=%d\n&v2=%d\n", &v1, &v2);
                exit(1);
        }
    Compiling with GCC, I get &v1 == &v2.  Compiling with VAX C I get
    &v1 + 4 == &v2.  In either case, I think it's wrong.  I think that
    I should get a linker error complaining about an undefined external
    variable (v1).

    Aren't I right?  Shouldn't the above program generate an error?  In
    which case, is this a bug in GCC (and VAX C) or in the VAX linker?
    (I think it's a fault of the linker).

David Newall                     Phone:  +61 8 343 3160
Unix Systems Programmer          Fax:    +61 8 349 6939
Academic Computing Service       E-mail: ccdn at levels.sait.oz.au
SA Institute of Technology       Post:   The Levels, South Australia, 5095



More information about the Comp.lang.c mailing list