thoth@shark.cis.ufl.edu (Robert Forsman) (12/02/89)
How many people have bastardized existing programs? I had a program written in pseudo-ANSI C (gcc -Wall didn't complain). Some of the data structures started to get really complex and I was beginning to lose track of what I was doing. I put the program on the back burner until we could get a working version of g++. We have g++ now and I finally have hacked the program until it will compile with minimal warnings. The major problem is it's now a mix of C++ and C. I have extern "C" statements everywhere to prevent name mungeing of functions called by the C parts. I also mix IO between cerr and stderr (no cout, I'm using sockets for all normal xactions). I've been getting SEGV inside of an fprintf statement. I converted it to a cerr << and it still SEGVs. If any of you guys can mail me hints, I'd really appreciate it. THOTH out -=O=- -- ( My name's not really Gilligan, It's Robert Forsman, without an `e' )
T.Day@ucl-cs.UUCP (12/07/89)
From: Tim Day <T.Day@uk.ac.ucl.cs> Something to watch out for: It's quite possible to write e.g stdout << "foobar" and similar things by accident. The type conversion attempts to convert stdout to an ostream (possible using the ostream constructors); there is be no warning message, but the program usually bombs in all sorts of strange places if you write stdout << "a" << "b" as the newly constructed ostream goes out of scope before the second operator<< is called; (except that it hangs around on the stack long enough to look like it had worked and/or screws up the stack to mislead the debugger). I suspect mixing cerr and stderr is asking for trouble. Either use one or the other, or perhaps derive your own ostream class and replace all the operator<< routines with stuff to access FILE*s (or cerr specifically) safely using fprintf. +-----------------------------------------------------------------------------+ Tim Day | Meet every second in life as challenge; Department of Photogrammetry | Respond fully to whatever happens UCL, Gower St., London WC1E 6BT | without anxiety, or complaint, or clinging +-----------------------------------------------------------------------------+