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
--69pVuxX8awAiJ7fD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Boy, I'm getting rusty at C++ now..=20 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 =3D "") : 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 -D= HSYSTEM_FILE -DHSYSTEM_DISK -DHSYSTEM_HUI -DHSYSTEM_SYSINSTALL -DHSYSTEM_DA= TABASE -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/datab= ase -lhdatabase -lstdc++ -ldisk -lfetch -lz -lcom_err -lm -ltcl83 -L/usr/lo= cal/lib -lm =2E./../../compile/none//libhfile.so: warning: mktemp() possibly used unsaf= ely; consider using mkstemp() =2E./../../compile/none//libhfile.so: undefined reference to `File::File(in= t)' 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. --69pVuxX8awAiJ7fD Content-Type: application/pgp-signature Content-Disposition: inline -----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----- --69pVuxX8awAiJ7fD-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-libh" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011204183451.GC2922>