April 6th, 2004, 07:46 PM
[BCB6] Access violation
A Borland C++ builder question...
I've got a bloody problem with my application that I can't manage to solve. I'd appreciate A LOT any help from you guys.
My application consists of several units with associated forms and 2 units without. In one of my units, when I include the header of a unit with a form, it's fine, but when I include the header of a unit without, I get a linker error with "Access violation, link terminated". And when I try to compile it again, I get "[Linker Error] Could not delete ProjectName.tds (project already open in IDE?)".
Does anybody have any idea of what the problem could be and how I can solve that? PLEASE...
Thanks a lot in advance.
April 7th, 2004, 05:17 PM
the linker creates the tds file, but if it doesn't finish properly the file can get "stuck". If you delete it manually you should be able to at least try again, which may help you figure out the first problem. Need more info before I could help youwith that.
April 8th, 2004, 02:24 AM
yep, every time I need to close BCB, delete the .tds file and then re-open BCB, and open all my units again... what a pain...
anyway, it's by doing that I discovered that compiling works fine when I include the header of a cpp with an associated form but not if there is no form...
I'm wondering if it's a problem to include too many headers in a cpp file, 'cause there is a lot a communications between my units, thus I need to include almost all the headers in each unit, in addition to some variables (arrays, structures... called by "extern"). Is it a problem? Is there a limit?
April 8th, 2004, 12:02 PM
Ran into something similar doing my senior project in college. I think the problem may be in part that the same headers are being pulled into a unit multiple times. ie, you have a unit myfile.cpp which needs to include header for unit myfile2.cpp (myfile2.h) as well as it's own header, myfile.h. Items declared in myfile2.cpp may be depedent on myfile.cpp, so it's header also includes myfile.h, and you can end up having the same things declared multiple times.
April 8th, 2004, 04:32 PM
Could be... but how can I avoid that? Put everything in a single cpp file??? sounds strange.
But I got a new error message that I don't like at all...:
I played a bit with the "include" order and the declaration of forms in the WinMain, and during a Make, I got an "Access violation" message, so I tried again and I then got that bcb.exe error:
"An exception (C0000005) occured during DllEntryPoint or DllMain in module C:\Program Files\Borland\CBuilder6\Bin\ilink32.dll"
Pretty bad, ay? Any idea?
April 9th, 2004, 09:30 AM
One solution is to use #ifndef pre-compiler directives. There is a thread going on this right now (or was yesterday) in the c++ forum. Another is to be careful how you implement your program- it should be possible to implement it so there isn't a loop like that.
Last edited by f'lar; April 9th, 2004 at 09:35 AM.
April 17th, 2004, 05:19 PM
OK IT WORKS!!!!
The problem was that I was declaring my global variables in the headers, resulting in multiple declarations by including the different headers in every cpp files…
Stupid mistake… 2 weeks to understand that… Programming can be so cruel sometimes!
Thanks anyway to everybody, this forum is great.