Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!nuchat!texhrc!ylc From: ylc@texhrc.UUCP (Yin L. Cheung) Newsgroups: comp.unix.ultrix Subject: Re: Problems with CC on DECStation 3100 Summary: Check external variables Message-ID: <502@texhrc.UUCP> Date: 22 Sep 90 15:57:51 GMT References: <68399@lll-winken.LLNL.GOV> Distribution: na Organization: Texaco Houston Res. Cntr Hou, Tx Lines: 37 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 #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 =======================