Topic: Initialization problem in BC++4.0
Author: sak@si.sintef.no (Steinar A Kindingstad)
Date: 28 Sep 1994 13:14:39 GMT Raw View
Have the rules for initialization changed from
Borland C++ 3.1 to Borland C++ 4.0?
Or has Borland C++ 4.0 just become smarter?
I have this code example that I just can't
get to compile with Borland C++ 4.0:
---------------------------------
struct mystr {int ok;} mystrcts[]={{2},{3},{7},{99}};
struct foo {struct mystr *tst;};
struct foo foo2[]={{mystrcts+2},
{mystrcts-2}}; <----Illegal initialization error.
---------------------------------
Is this always an illegal initialization?
The compiler gives an illegal initialization error at the last line.
The problem is that this piece of code compiles fine
with Borland C++ 3.1, but not with BC++ 4.0!
I suspect it has to do with addressing the basepointer
mystrcts negative (mystrcts-2), but I'm not sure.
(I know the example looks stupid, but it is constructed
from the original code and has no real function)
Can anyone give me any tips on what to do, because
I really need this code in my project.
Steinar