vlcek@mit-caf.MIT.EDU (Jim Vlcek) (02/19/89)
In article <807@atanasoff.cs.iastate.edu> hascall (John Hascall) writes: [In a discussion on using empty array declarations] > Of course, adding: > > #define N_FCONSTS (sizeof(fund_consts)/sizeof(double)) > > then you can use stuff like: > > extern fund_consts[N_FCONSTS]; > > elsewhere. > >John Hascall >ISU Comp Center Will this work? Presumably, both the #define and the extern declaration will be in a header file (funds.h, let's say). If we're compiling usesfunds.c, and we #include "funds.h", how does the compiler know the sizeof(fund_consts) to calculate the value N_FCONSTS? After all, the definition of fund_consts would be in funds.c, which we are presumably compiling separately -- it may even be in a library. I would think that all one can do in this case is #define N_FCONSTS to be some hard constant, or another expression which reduces to a hard constant evaluable at compile time in any module including funds.h. -- Jim Vlcek vlcek@caf.mit.edu !{harvard,rutgers}!mit-eddie!mit-caf!vlcek