Hello, I work at the U.S. Department of Labor, on the Unemployment Insurance program. I am working on developing a new Benefit Financing model for the state of Oregon, and I am having an issue with passing a struct between mutiple .c and .cfn files( the .cfn files are for the C cursor screens). The srtuct in question foloews:

extern struct{
        double x[6][30];
        double xtxy[6][5];
        double b[6];
        double bstde[6];
        double tval[6];
        double bset[3][6];
        double stats[6];
        double ajrsq,ystde,ymse,xtra1,xtra2,syy;}regrs_;

The struct is declared first in the main .c module, bsyrhd.c, and is further defined in a .cfn called later, invxtx5.cfn. Compiling the screen gives me the error:

"invxtx5.cfn", line 15: identifier redeclared: regrs_
        current : struct  {array[6] of array[30] of double x, array[6] of array[5] of double xtxy, array[6] of double b, array[6] of double bstde, array[6] of double tval, array[3] of array[6] of double bset, array[6] of double stats, double ajrsq, double ystde, double ymse, double xtra1, double xtra2, double syy}
        previous: struct  {array[6] of array[30] of double x, array[6] of array[5] of double xtxy, array[6] of double b, array[6] of double bstde, array[6] of double tval, array[3] of array[6] of double bset, array[6] of double stats, double ajrsq, double ystde, double ymse, double xtra1, double xtra2, double syy} : "bsyrhd.c", line 40

It seems obvious that I should just remove the declaration of the struct from invxtx5.cfn. However, when I do that, iget this error:

Undefined                       first referenced
 symbol                             in file
exp                                 bsyrhd.o
log                                 bsyrhd.o
pow                                 bsyrhd.o
fabs                                bsyrhd.o
sqrt                                bsyrhd.o
regrs_                              bsyrhd.o

My next thought was to remove the struct declaration from bsyrhd.c and put in back into invxtx5.cfn. When I do that, this is what happens:

"rgawb.cfn", line 52: undefined struct/union member: stats
"rgawb.cfn", line 52: warning: left operand of "." must be struct/union object
"rgawb.cfn", line 52: cannot dereference non-pointer type
"rgtxto.cfn", line 19: undefined symbol: regrs_
"rgtxto.cfn", line 19: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 19: cannot dereference non-pointer type
"rgtxto.cfn", line 19: cannot dereference non-pointer type
"rgtxto.cfn", line 20: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 20: cannot dereference non-pointer type
"rgtxto.cfn", line 20: cannot dereference non-pointer type
"rgtxto.cfn", line 21: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 21: cannot dereference non-pointer type
"rgtxto.cfn", line 21: cannot dereference non-pointer type
"rgtxto.cfn", line 22: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 22: cannot dereference non-pointer type
"rgtxto.cfn", line 22: cannot dereference non-pointer type
"rgtxto.cfn", line 27: undefined symbol: regrs_
"rgtxto.cfn", line 27: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 27: cannot dereference non-pointer type
"rgtxto.cfn", line 27: cannot dereference non-pointer type
"rgtxto.cfn", line 30: undefined symbol: regrs_
"rgtxto.cfn", line 30: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 30: cannot dereference non-pointer type
"rgtxto.cfn", line 30: cannot dereference non-pointer type
"rgtxto.cfn", line 31: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 31: cannot dereference non-pointer type
"rgtxto.cfn", line 31: cannot dereference non-pointer type
"rgtxto.cfn", line 39: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 39: cannot dereference non-pointer type
"rgtxto.cfn", line 39: cannot dereference non-pointer type
"rgtxto.cfn", line 39: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 39: cannot dereference non-pointer type
"rgtxto.cfn", line 39: cannot dereference non-pointer type
"rgtxto.cfn", line 40: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 40: cannot dereference non-pointer type
"rgtxto.cfn", line 40: cannot dereference non-pointer type
"rgtxto.cfn", line 40: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 40: cannot dereference non-pointer type
"rgtxto.cfn", line 40: cannot dereference non-pointer type
"rgtxto.cfn", line 58: undefined struct/union member: xtxy
"rgtxto.cfn", line 58: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 58: cannot dereference non-pointer type
"rgtxto.cfn", line 58: cannot dereference non-pointer type
"rgtxto.cfn", line 58: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 58: cannot dereference non-pointer type
"rgtxto.cfn", line 58: cannot dereference non-pointer type
"rgtxto.cfn", line 60: undefined struct/union member: bset
"rgtxto.cfn", line 60: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 60: cannot dereference non-pointer type
"rgtxto.cfn", line 60: cannot dereference non-pointer type
"rgtxto.cfn", line 66: undefined struct/union member: stats
"rgtxto.cfn", line 66: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 66: cannot dereference non-pointer type
"rgtxto.cfn", line 68: undefined struct/union member: stats
"rgtxto.cfn", line 68: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 68: cannot dereference non-pointer type
"rgtxto.cfn", line 69: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 69: cannot dereference non-pointer type
"rgtxto.cfn", line 73: undefined struct/union member: bset
"rgtxto.cfn", line 73: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 73: cannot dereference non-pointer type
"rgtxto.cfn", line 73: cannot dereference non-pointer type
"rgtxto.cfn", line 79: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 79: cannot dereference non-pointer type
"rgtxto.cfn", line 79: cannot dereference non-pointer type
"rgtxto.cfn", line 79: warning: left operand of "." must be struct/union object
"rgtxto.cfn", line 79: cannot dereference non-pointer type
"rgtxto.cfn", line 79: cannot dereference non-pointer type
"rgtur.cfn", line 13: undefined symbol: regrs_
"rgtur.cfn", line 13: warning: left operand of "." must be struct/union object
"rgtur.cfn", line 13: cannot dereference non-pointer type
"rgtur.cfn", line 13: cannot dereference non-pointer type
"rgtur.cfn", line 14: warning: left operand of "." must be struct/union object
"rgtur.cfn", line 14: cannot dereference non-pointer type
"rgtur.cfn", line 14: cannot dereference non-pointer type
"rgtur.cfn", line 15: warning: left operand of "." must be struct/union object
"rgtur.cfn", line 15: cannot dereference non-pointer type
"rgtur.cfn", line 15: cannot dereference non-pointer type
"rgtur.cfn", line 16: warning: left operand of "." must be struct/union object
"rgtur.cfn", line 16: cannot dereference non-pointer type
"rgtur.cfn", line 16: cannot dereference non-pointer type
"rgtur.cfn", line 30: undefined symbol: regrs_

Actually, there are more error messages than this, but the point is that none of the other cfns called by bsyrhd.c can find the struct without it being delacred in bsyrhd.c. My last try was to remove the extern part of the declaration from either the .c file or the .cfn file, but in both cases, I just received the redeclare error again. I do not know what to try next to resolve this issue. Any help with this problem is greatly appreciated.

Recommended Answers

All 4 Replies

Have you tried declaring the structure in a header and including it where needed?

Re. Tinstaafl's suggestion. Just make sure you guard the header from being included multiple times, or you will will have the same problem. Do you know how that works?

I have used .h files files frequently, my concern here was that screens are different compiling logic, because of the include of the <curses.h> GNU library, from OpenSource. My concern has sadly become reality, since the creation of the .h file below:

/***********************************************************************

   regrsh.h header file for the Projection program sreens of the benefit
   Financing Model for all states. Created by John McPherson,
   Powertek Corporation
   Rockville, MD 20850. May, 2017.

********************************************************************* */

extern struct{double \
        x[6][30],xtxy[6][5],b[6],bstde[6],tval[6],bset[3][6],stats[6], \
        ajrsq,ystde,ymse,xtra1,xtra2,syy;}regrs_;

produces the following compiling errors:

"nerrmsg2.cfn", line 16: warning: implicit function declaration: sleep
"center.cfn", line 6: warning: implicit function declaration: strlen
"regrsh.h", line 10: only "register" valid as formal parameter storage class
"regrsh.h", line 10: warning: dubious struct declaration; use tag only: <unnamed>
"regrsh.h", line 12: parameter not in identifier list: regrs_
"regrsh.h", line 10: only "register" valid as formal parameter storage class
"regrsh.h", line 10: warning: dubious struct declaration; use tag only: <unnamed>
"regrsh.h", line 12: parameter not in identifier list: regrs_
"rgqi.cfn", line 24: warning: implicit function declaration: mkxtxy_
"rgqi.cfn", line 25: warning: implicit function declaration: invxtx_
"regrsh.h", line 10: only "register" valid as formal parameter storage class
"regrsh.h", line 10: warning: dubious struct declaration; use tag only: <unnamed>
"regrsh.h", line 12: parameter not in identifier list: regrs_
"regrsh.h", line 10: only "register" valid as formal parameter storage class
"regrsh.h", line 10: warning: dubious struct declaration; use tag only: <unnamed>
"regrsh.h", line 12: parameter not in identifier list: regrs_
"regrsh.h", line 10: only "register" valid as formal parameter storage class
"regrsh.h", line 10: warning: dubious struct declaration; use tag only: <unnamed>
"regrsh.h", line 12: parameter not in identifier list: regrs_
"regrsh.h", line 10: only "register" valid as formal parameter storage class
"regrsh.h", line 10: warning: dubious struct declaration; use tag only: <unnamed>
"regrsh.h", line 12: parameter not in identifier list: regrs_
"regrsh.h", line 12: identifier redeclared: regrs_
        current : struct  {array[6] of array[30] of double x, array[6] of array[5] of double xtxy, array[6] of double b, array[6] of double bstde, array[6] of double tval, array[3] of array[6] of double bset, array[6] of double stats, double ajrsq, double ystde, double ymse, double xtra1, double xtra2, double syy}
        previous: struct  {array[6] of array[30] of double x, array[6] of array[5] of double xtxy, array[6] of double b, array[6] of double bstde, array[6] of double tval, array[3] of array[6] of double bset, array[6] of double stats, double ajrsq, double ystde, double ymse, double xtra1, double xtra2, double syy} : "regrsh.h", line 12
"regrsh.h", line 12: identifier redeclared: regrs_
        current : struct  {array[6] of array[30] of double x, array[6] of array[5] of double xtxy, array[6] of double b, array[6] of double bstde, array[6] of double tval, array[3] of array[6] of double bset, array[6] of double stats, double ajrsq, double ystde, double ymse, double xtra1, double xtra2, double syy}
        previous: struct  {array[6] of array[30] of double x, array[6] of array[5] of double xtxy, array[6] of double b, array[6] of double bstde, array[6] of double tval, array[3] of array[6] of double bset, array[6] of double stats, double ajrsq, double ystde, double ymse, double xtra1, double xtra2, double syy} : "regrsh.h", line 12
"bsyrhd.c", line 90: warning: old-style declaration or incorrect type for: main
cc: acomp failed for bsyrhd.c

I created the .h file in the same format the other .h files in the Benefit Financing Model. However, the .h files are used in the simulation code, which do not include <curses.h> ( They are the model in model-view-controller, the screens are the view). For reference, here is a .h file I use which compiles cleanly:

/***********************************************************************

   ff.h header file for the Financial Forecast program of the benefit
   Financing Model for benefit ratio states. Created by Paul Jiang, 
   ACS Government Services
   Group, Rockville, MD 20850. April, 2001.

********************************************************************* */

extern struct {int \
  ndis,jlcnt,kcd,kcy,kfpy,kfpy1,kfpq1,kqi,kqf,kyf,\
  kqs,kys,ktab,kta0,kta1,jl1,jl2,jl3,rateCnt[8];}all_;
extern struct {double \
  rbend[3],rbenr[3],rbene[3],rconr[3],rconp[3],\
  rcond[3],rcons[3],rconb[3],rintf[3],rconem[3];}actual_;
extern struct {double \
  dscr[12],cscr[12],nsc[12],scr[12],ttintf[12],povpay,\
  ovpay[12],pdelco,delcon[12],prelc,relc[12],pdeltx,\
  pminnc,mxben[12],minben[12],maxcon[12],mincon[12],\
  ajmxeb[12],minpay[12],maxbc[12],minbc[12],adjpay[12],benpyr[12],\
  ajmneb[12],benpay[12],maxbpr[12],dlf[12],ascr,wominb;int ial;}alab_;
extern struct {double \
  rconp0,rconp1,rconb0,rconb1,rcons0,rcons1,\
  rconm0,rconm1;}base_;
extern struct {double \
  benr[4][12],bend[4][12],bene[4][12],benre[4][12],\
  tben[4][12],tbenr[12][2],tbene[12][2],tbend[12][2],\
  tbena1[2][2],tbena[12][2],addmin[12];}ben1_;
extern struct {double \
  cbr[12][605],bratio[12],cbentt[12];}benra_;
extern struct {double \
  xinter,xintga; int kdeper,kdepga,kemeer,kemega,\
  kexter,kextga,kextsp,knber,knbga;}charge_;
extern struct {double \
  conrm[605],conr[605],conrprev[605],condm[605],conde[605],zr,zm,\
  conbm,conbe,conemm,coneme,conpm,conpe,consm,conse;}conef1_;
extern struct {double \
  ctrate[12],cttrig[12];int ict;}conn_;
extern struct {double \
  tconr[4][12],dconp[4][12],dcond[4][12],dcons[4][12],\
  dconb[4][12],dconem[4][12],tconf[4][12],tcon[4][12];}cont1_;
extern struct {double \
  tconra[12][2],tconp[12][2],tcond[12][2],tcons[12][2],\
  tconb[12][2],tconem[12][2],tconfa[12][2],tcona[12][2];}cont2_;
extern struct {double \
  ben[605],con[605],pben[605],ppay[605][2],\
  tax[605],tot[605],ttben,ttax,toben,totax;}dist1_;
extern struct {double \
  prben[605],pr1ben[605],pr2ben[605],fben[605],\
  prtax[605],pr1tax[605],pr2tax[605],ftax[605];}dist2_;
extern struct {double \
  bencer[12],bencin[12],bennc[12],beintr[12],crc[12],\
  hbcr[12],pintf[12],sfi[12],tintf[4][12],tca[12],jw_tca[12],\
  xminq1[12],xminq2[12];int kt[12]; char kttie[14];}impri_;
extern struct {double \
  paid[12],payln[4][12],repay[4][12],tcash[4][12],\
  qloan1[4][12],qloai1[4][12],tloan0[4][12],tloan1[4][12],\
  tloani[4][12],tloanm[4][12],tran[4][12],xloan0,xloan1,\
  xloani,xloanm,tln00,tln01;int kqp[12],ipay;}loan1_;
extern struct {double \
  pintl[12],xintd[4][12],xintq[4][12],xintqm[4][12],\
  tintl[12],pintmx;int idef[12],idisc[12],idmay[12];}loan2_;
extern struct {double \
  atr[12],bcr[12],rbt[12];int iapp[12],ioff5[12],\
  isat2[12],ipc83,ipc84,ipc85,itaxyr,isurtx[12];}loan3_;
extern struct {double \
  aben5[12],addtax[12],atr5[12],bcr5[12],ftwb[12],\
  factor[12],furate[12],futa[12],futac[12],\
  fucre[4][12],fupos[12],refuta[12],staaw[12],\
  statr[12],usaaw[12],futpe[12];int itran[12];}loan4_;
extern struct {double \
  bens1,bens2,bens3,bens4,bens5,pcap83,pcap84,pcap85,\
  rbt78,rbt79,rbt80,rbt81,rbt82;}loan5_;
extern struct {double \
  connew[4][12],paynew[4][12],pernew[12],pctxra[8],\
  yconew[12],head[3][10],pctnew;}newemp_;
extern struct {double \
  awwpc[5],fbrat[13],awwpr,e1,e2,e3,e4,e5,e6,e7,e8,\
  oinc[4][12],safbal[12],\
  con11,kkben[5];int kkstep[5],kkzero[5],\
  lkstp[13];double anks; int maxbas,nkstep,nks0,iok;}okla_;
extern struct {int \
  maxx,kbrny,kemc,keme,kext,kmaxt,kni,kny,knyner,\
  kpy,kri,krr,krs,krt,ks,ktt,ktttny,ktxny,kucf;}param_;
extern struct {double \
  xcrei1,xintg1,xintr1;int kext1,kchae1,kchad1,kcrnb1,\
  kcree1,keme1,kemc1,kny1,krt1,kst1,ktt1;}param1_;
extern struct {double \
  xcrei2,xintg2,xintr2,kext2,kchae2,kchad2,kcrnb2,\
  kcree2,keme2,kemc2,kny2,krt2,kst2,ktt2;}param2_;
extern struct {double \
  xqi[3],xpro[3],xtbpc,xtbpm,xtbca; int kbintr;}parben_;
extern struct {double \
  xfbrmi,xfbrcs,xfbrra,xfbrw0,xextmi;}paremg_;
extern struct {double \
  fbr[4][12],xdep,xdelco,xemr,xmisco,xpext; int ke,kd;}parext_;
extern struct {double \
  pbend[12],pbene[12],pbenr[12],pbent[12],pbento[12], \
  pconr[12],pconp[12],pcond[12],pcons[12],pconem[12], \
  pconb[12],pcredt[12],pcont[12],pconto[12],taxtot[12];}prop_;
extern struct {double \
  awba[12],awwa[12],awbq[4][12],ebc[4][12],\
  mtwb[12],taxafed[12],qia[12],qt[12],qiq[4][12],qth[2][12],\
  twcd[4][12],twce[4][12],twcr[4][12],xur;}regres_;
extern struct {double \
  coveq[4][12],covea[12];}covemp_;
extern struct {double \
  sumben[13][50],sumtax[13][50],sumtot[13][50],\
  sumcon[13][50],dcon[605];}sumdis_;
extern struct {double \
  xperct[12];}t4tot6_;
extern struct {double \
  cla,clb,clc,clk,cna,cnb,cnc,cnk,dfmax,dfcr0,dfcr1,\
  floor,genmax,pceil,pfloor,pbnew,percls,perwar,\
  xopi,xop1,xop2,xopd2,xopd3,xopd4,smtjb[605],\
  tsmtjb[4][12],tbalsj[4][12],tsjgtf;int itx,ndtx,kqsol,\
  kysol,ismtjb[12]; double prvcpm,prvcp;}texas1_;
extern struct {double \
  chomax[12],dfcr[12],funhi[12],funlo[12],pbcls[12],\
  paycls[4][12],rpnm[12],surp[12],xtri[90],\
  efbenc[12],tbenre[12],benwar[12],ovpaid[12];}texas2_;
extern struct {double \
  genr[605],qcredt[4][12],scon[605][12],xcredt[605],\
  xcond[605],xconp[605],xconr[605],xcons[605],\
  tconx[605],tcony[605][12],tconyf[605][12],\
  tcredt[605][12],tcreda[12][2];}texas3_;
extern struct {double \
  xbri[81],xrate[82][15],xtrig[14],rktreg[12]; char ktti[16]; \
  int knri,knt;}trig_;
extern struct {double \
  fundbb[605],fund[605],fundt[4][12][2],funds[4][12];}trust_;
extern struct {double \
  fbf[12],fundbr[12],pcr[13],pool[12],percen[12],\
  ccpay[12],fbdr[5],fbtrig[4],hiben[7],bkval[7], \
  fbrlim,fbrli2,floor2,pay1,pay2,pay3,\
  pool1,pool2,pool3; int iopt,iyr,iva,ifbf,ihiyr[7],iyrbk[6];}vatax1_;
extern struct {double \
  payyf[13][2][2],tbenaf[13][2],tti[13],perev;}vatax2_;
extern struct {double \
  cfr[13],ctrig[280],cutax[280],hhbcr[13],\
  pcutax[280],resmul[13],pzero[13],c1,c2,c3,c4, \
  ortot[13][2],ormin,ormax;int ior;}oregon_;
extern struct {double \
  pay[4][12][2],payy[12][2][2],payc[12][2],jw_pay[4][12];}wages_;
extern struct {double \
  fundct[12],sbcona[12],wfbr[12];int iwa;}wash_;
extern struct {double \
  hibcr[3],avhbcr[12],curbcr[12],avhcm[12],reedcn[12];}reed_;
extern struct {double \
  ai[4],aj[4],ailfo[12],ailfq[12],\
  cieq[4],credin[2],ppp[19],ratlf[4],uiq[4],uri[4],\
  uu[4],xpc[4],tlfi,xuj,ratilf,xtwce3;int kieq;}pilf_;
extern struct {double \
  sfiadj[12],genrate[12],sfifac[10],ttbenp[12],\
  ttpayy[12],xnonben[12],bnewn[12],xineb[12],\
  xineff[12],xinefchr[12],xsfieff[12],gxrtaj[12];}missi_;
extern struct {double \
  szindx,coeff,bnper,xinper,xinteff,ttbenp2,sfiadd,\
  acrtgt,wageadj,xmintx[12],xmaxtx[12],xmincbr,xmaxcbr; int \
  iymntx;}missi1_;
extern struct {int \
  ims;}missi2_;
extern struct {double \
  cr[20]; int icryr[20]; double adqres[12],resfac[12],socrt[12];}utah_;
extern struct {int \
  iut;}utah2_;
extern struct {double \
  rtmax[12],rtmin[12],flfbf[12],grosbr[12],rmult[12],\
  pnchg[12],finaj[12],fbtrgp,fbtrgn,xsben;}fla_; 
extern struct {int \
  ifl;}fla2_;
extern struct {double \
  highcstprdEmply,highcstprdWklyBen,highcstprdBenf;}ore1_;

/* real*8 mtwb,maxcon,mincon,mxben,minben,minpay,nsc,maxbpr,maxbc,
     1       minbc */

I use this .h file to compile the Financial Forecast simulation code, and it compiles cleanly. Since I used the same format to create the regsh.h file, I am not sure where the problem is occuring, other than the <curses.h> inclusion requires a special .h format.

The problem with the .h file turned out to be in the command line, I needed to add the -lm option to the compiler call. The screen compiles fine now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.