Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Abnormal Program Termination when I write to open ofstream 2

Status
Not open for further replies.

biot023

Programmer
Nov 8, 2001
403
GB
Hallo.
I have an ofstream (called "file", originally enough) that has opened (tested it with is_open()) and has physically been created (I went & looked in the directory it was supposed to open into).
The trouble is, I can't get my program to write to it - nothing appears, and I get an Abnormal Program Termination or an EFFACE (whatever that is) when I try an endl or "\n" and am sent to the CPU window, where I really am lost.
Does anybody have any idea what this could be?
& how it might be fixed?
Cheers,
Douglas JL.

A salesman is a machine for turning coke into obnoxious arrogance.

Common sense is what tells you the world is flat.

 
Could be related - I'm getting a load of linker warnings, as well.
The help file isn't very, but it's telling me:
Public symbol symbol defined in both module module1 and module2
There is a conflict between two public symbols. This means that a symbol is defined in two modules.

Looking closer, it appears to refer to the << operator, but I damn' sure haven't overloaded it or #defined it away!
Does this offer any clues to anyone?
Cheers,
DJL

A salesman is a machine for turning coke into obnoxious arrogance.

Common sense is what tells you the world is flat.

 
A puzzler! Have you included the iostream header file in both modules?


James P. Cottingham

There's no place like 127.0.0.1.
There's no place like 127.0.0.1.
 
Yeah, man - but I commented all #include<fstream> directives out of all but one h file, and I'm still getting the problem.
Cheers,
DJL

A salesman is a machine for turning coke into obnoxious arrogance.

Common sense is what tells you the world is flat.

 
Also commented out the <ofstream> header, sorry!
I've never had a problem w/ multiple declarations before - I'm bound to have done it w/ <ostream> & <fstream> a million times!
Also - is that what it means by 'module' - header file?
The problems are all listed as being in the .OBJ files, I don't know if that helps illuminate anything.
Thanks again,
DJL

A salesman is a machine for turning coke into obnoxious arrogance.

Common sense is what tells you the world is flat.

 
I've never had problems with including multiple instances either but then again, I've never seen this problem before. Have you tried deleting all your *.obj files and recompiling them? Make sure you have a backup first.



James P. Cottingham

There's no place like 127.0.0.1.
There's no place like 127.0.0.1.
 
Yeah - tried that, too!
It is flagging the linker warning regarding the << operator between all the possible *.OBJ files that it can! I definately have only one #include<iostream> and one #include<fstream> in the whole of the program, now, so I can only think this is maybe a compiler error?
God, I hope not!
I've been on this for days!
DJL

A salesman is a machine for turning coke into obnoxious arrogance.

Common sense is what tells you the world is flat.

 
I use streams alot and I've never seen this type of error before but I've had odd problems with getting invalid pointers, etc. on compiled files even though I know the files are OK. Have you tried deleting all your associated *.ddp, *.tds, and (maybe) your *.res files, too. Make sure you have a good backup of all the files first!

Next time you start BCB, it should warn you that some files are missing and ask if it should recreate them. Say OK and see what happens. Sometimes this works and sometime it makes things worse, hence the above warning.

James P. Cottingham

There's no place like 127.0.0.1.
There's no place like 127.0.0.1.
 
Howdy,

I aggree w/ 2ffat. I would "dispose" of all those files. The way I usually do it, is to just drag them into a "New Folder", then rebuild the project before trying to execute. Seems to me that it is much more reliable that way. But I am a moron, and usually screw things up somehow...

Then there is always the magic key code Ctrl+A, DELETE.[thumbsup2]

Well good luck,
onrdbandit

No! Try not. Do, or do not. There is no try. - Yoda
 
Tried it, man, to no avail!
Got rid of the all *.res, *.tds, *.dsk, and *.obj files, and the same linker warnings appeared & the same error when I tried to run it.
Damn', this is frustrating!
D'you think I could use some other way of writing to file?
Maybe file.write("whatever") or something?
This could solve the short-term problem, as it is only the << operator mentioned in the linker warnings.
& cheers for the suggestions so far!
DJL

If I had a hammer...
 
Hi,
I had the same problem and solved it.
My project linked two modules that exposed symbols coming from STL twice. This is because these modules were linked with different options:

Module1 had
Options->Linker->Use dynamic RTL = ON
Options->Packages->Build with runtime packages = ON

Module2 had
Options->Linker->Use dynamic RTL = OFF
Options->Packages->Build with runtime packages = OFF

I hope this help

Luca C.
 
Hi lucastle74 - sorry I haven't replied sooner - I've been away on holiday (lucky me).
But that sounds like possibly the kind of thing I'm on about.
My problem now would be I know nothing of modules & their settings! I very simplistically understand there is a project, then the header files & CPP files in it, but after that I'm more than a bit lost.
How do I access these modules & then their settings so I can see & alter them?
& thanks alot!

doug.

If I had a hammer...
 
The term "module" usually refers to what you get by compiling a single source file (.CPP file in your case). That is, "module" is usually synonymous with ".OBJ file" on Windows.

Modules usually contain references to symbols defined in other modules. These references are resolved by combining (through the process known as "linking") the .OBJ files into a single .EXE file.

You could also say that a .LIB (library) and a .DLL (dynamic library) contain modules. They're just "packages" of .OBJ files... sorta.


So in response to your earlier question: no, a module is not a header file. Header files get literally included into source files, and so the declarations made in a header file can appear as symbols in modules created from source files that #include that header. Symbols generally will only appear if they are used in the source code (that's a lie, but it's close enough).


When you compile:
Code:
#include <cctype>
#include <iostream>

int main()
{
    return std::isalpha( '7' );
}
the symbol "isalpha" appears in the resultant module. When linking happens, the linker tries to find a definition for it. In this case, the definition will come from a module within the Standard Library.


So... that's probably more than you wanted to know. Sorry about the ramble.
 
No, man - any & all information is always more than welcome!
Thanks alot for that, everyone - I'm gonna go play & see if I can't make the damn' thing work.
Cheers again,
doug.

If I had a hammer...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top