Date: Tue, 4 Dec 2001 13:34:52 -0500 From: The Anarcat <anarcat@anarcat.dyndns.org> To: Libh <freebsd-libh@freebsd.org> Subject: File constructors Message-ID: <20011204183451.GC2922@shall.anarcat.dyndns.org>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] Boy, I'm getting rusty at C++ now.. Ahem, I'm trying to fix (yes fix) the File constructor. The simpler one (File()) doesn't initialize mFile so when it tries to close it, it crashes. There is a simple fix, but I think the more general one is to use a single constructor with a default value: File::File( const string& aUrl = "") : mUrl( aUrl ), mRemoveOnClose( false ), mFile(NULL) However, it doesn't really work. I made a little test program for the File class, since I'm tearing it apart; I want to see if it still works. ;) c++ -g -fpic -DPIC -I/usr/local/include/tcl8.3 -g -I../../../include -DHSYSTEM_FILE -DHSYSTEM_DISK -DHSYSTEM_HUI -DHSYSTEM_SYSINSTALL -DHSYSTEM_DATABASE -DSTATIC -c test_stub.cc cc -g -fpic -DPIC -I/usr/local/include/tcl8.3 -o test_stub test_stub.o -L../../../compile/none/ -L../../../lib/tcl -L../../../lib/common -lhtcl -lh -L/u/anarcat/libh/lib/file/test -L../../../lib/file -lhtclfile -lhfile -L../../../lib/disk -lhtcldisk -lhdisk -L../../../lib/hui -lhtclhui -lhui -L../../../lib/sysinstall -lhtclsysinstall -lhsysinstall -L../../../lib/database -lhdatabase -lstdc++ -ldisk -lfetch -lz -lcom_err -lm -ltcl83 -L/usr/local/lib -lm ../../../compile/none//libhfile.so: warning: mktemp() possibly used unsafely; consider using mkstemp() ../../../compile/none//libhfile.so: undefined reference to `File::File(int)' Now there is so much meta-language stuff in libh that I have a hard time tracing this back. And I don't remember if using a default is a proper way. It does seem so to me, but I remember having problems with that in the past too. Needless to say, I don't know why or how libhfile would access File(int). It does not make any sort of sense. Anyways, i'll just make 2 constructors. It's just that the error of not initializing mFile was made in only one of the two, and having a single constructor helps avoiding this kind of error. a. [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjwNF0oACgkQttcWHAnWiGe8HQCeIe/6yGR0zQ+xAd8te+SBC20D 1usAn1RapYppB1ITS2AT/hsq81U8g5Ae =0pJy -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011204183451.GC2922>
