Problems with CC on DECStation 3100

Yin L. Cheung ylc at texhrc.UUCP
Sun Sep 23 01:57:51 AEST 1990


I've seen the "gp relocation" errors when external variables are
not declared and referenced consistently.  For example, when a variable is
declared as a structure and then externally referenced as a pointer to
structure.  "Lint" should uncover the inconsistency.  Below is an example
that generates "gp relocation" errors:

h1.h:
	typedef struct {
	    int len;
	    char data[256];
	} CountedString; 
c1.c:
	#include <stdio.h>
	#include "h1.h"
	CountedString cs = {5, "abcde"};
	func(ccs)
	    CountedString *ccs;
	{
	    int i;
	    for (i=0; i < ccs->len; i++) fputc(ccs->data[i], stdout);
	}
c2.c:
	#include "h1.h"
	extern CountedString *cs;
	main() {
	    func(&cs);
	}

Note that "cs" is declared inconsistently across c1.c and c2.c.  This
example will not link on the DS3100, but for reasons I don't understand
will link and run on a SPARCstation.

=======================
Yin Cheung, Texaco Inc.
convex!texhrc!ylc
=======================



More information about the Comp.unix.ultrix mailing list