Sorry this is a very newbie question.
We have this massive application I am doing maintenance on. It has 5 different forms. We put our global variables in one unit (uGlobal). But i can't seem to access it from the data unit (uData).
I have this:
Unit uGlobal
type
TmyType: (alpha, beta);
...
Unit uGlobal
Stuff: TmyType <- error, undeclared indentifier
When i try to put uGlobal in the uses section of uData, it complains of a circular reference. So, kinda clueless here. They are both in the same project. This is using BDS 2006.
You have a circular reference because you have things in uGlobal that want to make use of things in uData and vice-versa. Circular references are a big concern in large projects because they greatly increase complexity - if you have circular dependencies, it becomes more like one BIGGER unit. I suspect you have a long way to go before your project can be considered large, let alone "massive". ;)
You have 2 possible solutions:
David has already given the answer: At least one of the units must use the other from the implementation section.
uData interface and referenced that in uGlobal interface, then the interface of uGlobal needs uData and will need a corresponding uses clause.uData implementation that's referenced in anywhere uGlobal, then that declaration in uData implementation must be moved to the interface section.uGlobal interface must it's only referenced from the implementation section of uData then that uses clause will be fine in the implementation section.Removing the circular dependency requires breaking your units down into smaller ones that are more manageable. To do this, you must understand the dependencies between each of the things in your application. For example:
uGlobal declares A and CuData declares B which needs CAll you have to do in this case is declare a new unit at move C in there.
uGlobal and uData will use uNewUnit
I am not in any way advocating your approach with uGlobal. In fact it is a very bad idea and will bite you big time on 2 fronts when your projects starts to get large. Unfortunately the explanation is a mammoth answer in itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With