HDTenEightyP/NetNews huggingface dataset:
From: acanter@sdcc3.ucsd.edu (Adriaan Canter)
Newsgroups: comp.lang.c++
Subject: Turbo C++ Memory Managment On the PC
Keywords: Memory Heap
Date: 21 Aug 92 13:22:12 GMT
Distribution: ca


Hello, I've noticed that Borland Turbo C++ (v 1.0) will actually reserve 16
bytes when the "new" function is used to allocate space for a 2 byte
integer, i.e. the following code:

int * intptr;
intptr = new int;

will allocate 16 bytes, as measured using the "coreleft()" function,
under the small memory model. A subsequent second allocation of this type will
fit the second integer into the first 16 byte space allocated, but a third call
will block off an additional 16 bytes, and so on, so that 4 two-byte integers
will take up 32 bytes of space, for example. I guess this happens because some
space is reserved to point to the next location in the heap, although the
amount seems excessive. This is pretty wasteful of course, if I want to
dynamically allocate alot of structures. Is there anyway I can control how
much memory is actually reserved when the "new" function is called? Do the
newer versions of C++ have some memory managment classes (as I've over-heard)
that can fix this? Or do I have to finagle my own scheme, overloading the
"new" and "delete" operators. Forgive me if this is a dumb question, but my
manuals don't say very much about it. Thank you.

                                        Adriaan Canter
Newsgroups: comp.lang.c++
From: dsf@cray.com (Dan Frankowski)
Subject: Re: Is there a FAQ
Summary: Here's where you get the FAQ!
Organization: Cray Research, Inc.
Date: 20 Aug 92 09:41:29 CDT

In article <1992Aug20.065425.8076@ccsun7.csie.nctu.edu.tw> you write:
>I've been here for about one month.
>But never saw a FAQ.
>I guess there's not one.
>Am I right?

No.  Only two days ago I posted a message saying where the FAQ was.
(Exasperated grin.)  I know you have no bad intentions, but _why_ is
it so difficult to find the FAQ?

From the FAQ:

	Availability:	This is available via anonymous ftp
			from: sun.soe.clarkson.edu [128.153.12.3]
			in the file: ~ftp/pub/C++/FAQ

	Without FTP:	You can also get it by sending electronic mail:
			|	To: archive-server@sun.soe.clarkson.edu
			|	Subject: send C++/FAQ
			This will help those who don't have ftp.

	See also:	comp.lang.c's FAQ appears at the beginning of every
			month in that newsgroup, and is maintained by
			Steve Summit (scs@adm.mit.edu).

	Author contact:	Marshall Cline
			Paradigm Shift, Inc
			65 N. Main St. / Norwood NY 13668-1121
			voice:315/353-4585, fax:315/353-6110
			email:cline@sun.soe.clarkson.edu

	Copyright:	Copyright (C), 1991,1992 Marshall P. Cline, Ph.D.

>Yuan
>+----------------------------------------------------------+
>| Internet Address         : jypai@csie.nctu.edu.tw        |
>| NeXT mail GLADLY accepted: jypai@ccnext.csie.nctu.edu.tw |
>+----------------------------------------------------------+

DISCLAIMER: This ain't official Cray business.

-- 
Dan Frankowski            Dan.Frankowski@cray.com     (612) 683-5099
From: a_mahmoo@edrc.ac.uk (Arshad Mahmood)
Newsgroups: comp.lang.c++
Subject: BCC 3.0 and 3.1
Date: 17 Aug 92 14:51:04 GMT
Organization: Engineering Design Research Centre

Can any kind soul send me the details of the differences between Borland
C++ 3.0
and 3.1. I bought the BC 3.0 and Application Frameworks a few months back, I
also filled in my little card for upgrade info unfortuantely Borland UK
have not sent
my any info at all on the upgrade. 

If this information has already been broadcast then please accept my
apologies, you
folks generate so much news it's impossible to keep up :-)

Regards,
A.Mahmood
Systems Manager
From: shite@sinkhole.unf.edu (Stephen Hite)
Newsgroups: comp.lang.c++
Subject: Re: PD C++ => C translator wanted
Date: 19 Aug 92 03:43:24 GMT
Organization: University of North Florida, Jacksonville

In article <92224.080629WJCMS@CUNYVM.BITNET> WJCMS@CUNYVM.BITNET writes:
>FAQ tells me that there are many C++ => C translators. Can anyone point to me
>a public domain one? I'd like to start doing C++, but since I'm not sure yet
>what will be the programming platform, I don't want to spend too much money
>in the beginning. I'd rather get C++ => C translator and have a littlemore
>freedom of choice.
>
>
>Thank You,
>Janne Ravantti

  The g++ compiler, that's your only freely available choice.
You will not find a PD C++ -> C "translator."  

Steve Hite
shite@sinkhole.unf.edu
  
Newsgroups: comp.lang.c++
From: pjl@sparc10.cs.uiuc.edu (Paul Lucas)
Subject: Re: Proposal: auto T&
Organization: University of Illinois at Urbana-Champaign
Date: Thu, 20 Aug 1992 21:34:17 GMT

In <9223406.29682@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:

>pjl@sparc10.cs.uiuc.edu (Paul Lucas) writes:

>>In <1992Aug19.234913.622@tfs.com> eric@tfs.com (Eric Smith) writes:
>>
>>>Much recent discussion about destruction of temporaries suggests a
>>>better way to solve the whole problem, and to allow returning references
>>>to temporaries from functions.
>>
>>>auto String& stringfunction(const String& input)
>>>{
>>>   // Calculate/create a new temporary or named automatic String
>>>   // and return a reference to it.
>>>}
>>
>>>The "auto" in the function return value type tells the compiler to allocate
>>>the space for that automatic in the stack frame of the caller, instead of
>>>the stack frame of the called function.
>>
>>*****>	It's not reentrant.
>>
>>	String a, b, c;			// also assume + has been overloaded
>>	// ...
>>	a = stringfunction( b ) + stringfunction( c );

>Huh?

>What do you mean by "it's not reentrant"? Why not?

*****>	Because the "slot" allocated in the caller would first receive
	the temporary generated by "stringfunction( b )" then it would
	be clobbered by "stringfunction( c )" and clobbered yet again by
	the temporary generated by operator+, assuming it also used this
	proposed technique.  This assumes that there is one "slot"; a
	compiler-writer could count the number of times an auto& is
	called in the same expression and reserve that many slots so
	that none would get clobbered.

	The problem with that is, what does the compiler do if a
	function returning an auto& calls itself?  Or two such functions
	calling each other recursively?  The proposed semantics says that
	the slot goes in the caller; well if a function is itself the
	caller, you've got problems because you can't know ahead of time
	how many slots to allocate.
-- 
	- Paul J. Lucas				University of Illinois	
	  AT&T Bell Laboratories		at Urbana-Champaign
	  Naperville, IL			pjl@cs.uiuc.edu
Newsgroups: comp.lang.c++
From: kv07@IASTATE.EDU (Warren Vonroeschlaub)
Subject: Public domain x-windows library
Reply-To: kv07@IASTATE.EDU (Warren Vonroeschlaub)
Organization: Ministry of Silly Walks
Date: Tue, 18 Aug 1992 16:32:34 GMT

  The university I am working at refuses to shell out the money for commercial
libraries for x-windows.  Are there any fairly decent, relatively cheap
registration, libraries for x-windows?

  Better yet, does anyone have code that reads a 2-d array, opens an x-window,
and graphs a 3-d plot of the data, preferably with the ability to rotate the
graphs?  This is the main problem I am running into.

 |  __L__   *******************************
-|-  ___    * Warren Kurt vonRoeschlaub   *
 |  | O |   * kv07@iastate.edu            *
 |/ `---'   * Iowa State University       *
/|   ___    * Math Department             *
 |  |___|   * 400 Carver Hall             *
 |  |___|   * Ames, IA  50011             *
 J  _____   *******************************
Newsgroups: comp.lang.c++
From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
Subject: Re: Handling of operator . pro
Organization: MAXTAL P/L C/- University Computing Centre, Sydney
Date: Wed, 12 Aug 1992 14:38:37 GMT

In article <9222521.4872@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
>jimad@microsoft.com (Jim Adcock) writes:
>
>>maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
>>|And just like C++, there was never a compiler that actually worked.
>>|I do not understand why language implementors cannot get C++
>>|to work, but there it is: I'll bet there is not a single C++
>>|compiler that works.
>>
>>Kind of hard to argue whether or not a compiler meets the language
>>specification when there is no language specification.  If and when we
>>have an ANSI/ISO spec, and if the results truly are a spec, not just a
>>"standard", then it becomes possible to argue if when and how a
>>compiler "works" or not.
>
>When a compiler reports internal errors, dumps core, loops forever,
>or hangs your machine, then you know the compiler doesn't work. All the C++
>compilers I have ever used have one or more of these failings.
>
>Is there anyone out there who thinks their C++ compiler works?
>

	Interestingly, this sort of failure is less of a concern to
me than

	a) the compilation completes, but the generated code doesn't work.
	b) The compiler complains of an error when there isnt one.
	c) The compiler doesnt complain of an error when there is one.

Compiler hangs and crashes I can work around, usually. Incorrect
generation of constructors, failure to recognize when a class is 
concrete, failure to perform simple floating point operations:
these are harder to live with.

Personally, I wish the compiler vendors would concentrate on
*getting it right* first and worry about optimisation and
compilation speed afterwards.
Sometimes I think they don't even bother to test their compilers.

I for one, despite liking C++, would hesitate to recommend it for
a serious development project. 
-- 
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
Newsgroups: comp.lang.c++
From: fjh@mundil.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: destruction of temporaries
Organization: Computer Science, University of Melbourne, Australia
Date: Fri, 21 Aug 1992 16:58:13 GMT

tmb@arolla.idiap.ch (Thomas M. Breuel) writes:

>In article <23507@alice.att.com> ark@alice.att.com (Andrew Koenig) writes:
>
>   The trouble comes with expressions like
>
>	   foo().bar().baz()
>
>   where bar returns *this. If an implementation is allowed to delete
>   the result of foo() before calling baz, the roof can cave in even
>   if your defensive rules are followed.
>
>Read my paragraph again. I explicitly stated you shouldn't return a
>reference to "*this".

What about

	cout << "Hello World" << endl;

Does this mean that we have to go back to printf?

-- 
Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
This .signature VIRUS is a self-referential statement that is true - but 
you will only be able to consistently believe it if you copy it to your own
.signature file!
From: davidc@brahms.udel.edu (David Casper)
Newsgroups: comp.lang.c++
Subject: disp.h for BC/C++ Yes/No? Where...Al Stevens...*.hpp?
Date: 20 Aug 92 03:30:58 GMT
Article-I.D.: news.Bt9J3M.CHL
Organization: University of Delaware

Help!
Is there a "disp.h" for DOS|BC/C++ ???
Is there a "stream.hpp" ???
What does "*.hpp" stand for ???
What is Dr. Dobbs ???
What/which publication(s) does Al Stevens write for ???
 
Any help will be greatly appreciated.
Thanks
David (davidc@brahms.udel.edu)

-- 
David W. Casper
davidc@brahms.udel.edu
From: matt@centerline.com (Matt Landau)
Subject: Re: Return value for the constructors.
Organization: CenterLine Software, Inc.
Distribution: usa
Date: Thu, 20 Aug 1992 13:45:43 GMT

In <2273@devnull.mpd.tandem.com> rgp@mpd.tandem.com (Ramon Pantin) writes:
>>>Sure there is: Overload operator new()...
>>
>>*****>	Clever...but it's not reentrant.

>Paul, that is a moot point given that the object might not always be
>created thru new.  All the flag setting/checking by Josh's overloaded
>new ends up being ignored for automatic objects (i.e. local variables).
>The fact that an object wants to allocate memory thru new for its internal
>use doesn't imply that the object itself will always be created thru new.

Of course it's fairly straightforward to FORCE all objects of a given
class to be created via the class operator new (some some other delegated
creation function).  Simply design that class so that it has no public
constructors, and make the default constructor private.  The compiler
will now refuse to let either application-level code or subclasses call
any constructor for the class.  If you want subclasses to have direct
access to the constructors, make them protected instead of private.

Arrays are still a problem; if the default constructor for a class X is 
non-public, it's not legal to say "X x_array[size];" or to dynamically 
allocate an array of X with "X *xlist = new X[size];"  It's not that you
get an array whose members have not gone through X::operator new, but
rather that you can't get an array in the first place.

Presumably this limitation would go away if X3J16 actually designed an
operator new[] and someone actually implemented it :-)
Newsgroups: comp.lang.c++
From: mittle@watson.ibm.com (Josh Mittleman)
Subject: Re: con/destruction of fundamental type
Date: Thu, 20 Aug 1992 17:32:11 GMT
Disclaimer: This posting represents the poster's views, not necessarily those of IBM
Organization: IBM T.J. Watson Research Center

Jonas Nygren writes:

> I am trying to manage memory allocation, con- and destruction in my own
> code.  I also want these operations to work for struct/classes as well as
> fundamental types, int, char aso. 

> How do you do this in C++?

Overload ::new().  Memory mangagement is hadled by oeprator new(), not by
the constructor: The constructor simply initialized the blcok of memory
once it has been allocated. 

===========================================================================
Josh Mittleman (mittle@watson.ibm.com)
J2-C28 T.J. Watson Research Center, PO Box 704, Yorktown Heights, NY  10598
From: niklas@appli.se (Niklas Hallqvist)
Newsgroups: comp.lang.c++
Subject: Re: Garbage Collection for C++
Date: 16 Aug 92 01:10:05 GMT
Organization: Applitron Datasystem AB, GOTHENBURG, SWEDEN

I just wanted to say that conservative GC won't really help in all
situations.  Jonathan Shapiro taught me this useful trick once.
When you want to do a doubly linked list to the cost of a singly
linked one (i.e. in mem. space).  Instead of having two pointers
for the link in each node, take the "previous" and "next" pointers
and XOR them, and store the result!  Now you just need to store two
entry consecutive points into the list, and make an iterator intelligent
enough to work things out.  This is of course a very special trick,
but it IS useful, and it shows NO GC strategy always wins unless the
programmer explicitly can tell what objects are live/dead, but then
again, we're back to explicit memory management.

Niklas

-- 
Niklas Hallqvist	Phone: +46-(0)31-40 75 00
Applitron Datasystem	Fax:   +46-(0)31-83 39 50
Molndalsvagen 95	Email: niklas@appli.se
S-412 63  GOTEBORG, Sweden     mcsun!seunet!appli!niklas
Newsgroups: comp.lang.c++
From: cp79111@csie.nctu.edu.tw (Kuo-Ping Hsu)
Subject: help!!!
Organization: Computer Science & Information Engin., Chiao-Tung U, Taiwan, ROC
X-Newsreader: Tin 1.1 PL3
Date: Tue, 18 Aug 1992 06:33:38 GMT

hello,everybody :
        I want to write a program about RS232 communication routine, 
    but some trouble happened. Could you help me?
        I use Borland C++ 3.0 compiler and write a following program. There is
    a class called 'comm' with a syntax error in the constructor.
    I want to write a new IRQ interrupt service routine to replace old one.
    So, I must set new vector to point new ISR. I use Borland's
    run-time function 'void setvect(int int_no,void interrupt (*isr)())'.
    The second parameter must be a address that point to new IRQ. In my
    program, there is a statement like this :

         setvect(com_irq,&comm::NewIRQ);
                         ^^^^^^^^^^^^^
    But the compiler reports a following error :

         Error : Connot convert 'void (far interrupt comm::*)()'
                 to 'void (interrupt far *)(...)'
    If I write :

         setvect(com_irq,NewIRQ);
                         ^^^^^^
    then, there is a new fault

         Error : Member function must be called or its address taken.

    How can I solve this problem? If you know. Please reply me via E-mail.
    Thank you very much in advance.
-----------------------------------------------------------------
/VVVVVV\   
|    ^ |   E-Mail : cp79111@csie.nctu.edu.tw
|    O |   National Chiou Tung University
|@      )  Taiwan R.O.C.
\   `--/
  |  |
========                                       Kuo-Ping Hsu
----------------------------------------------------------------------------

===== File : RS232.HPP ======================

        :
        :
class comm {
    private:
        :
        :
      void interrupt NewIRQ();          // new IRQ interrupt service routine
      void interrupt (*OldIRQ)(...);    // save old IRQ
    public:
      comm(int port_no,int baud,char parity,char length,char stop_bit);
        :
        :
      char recv();          // receive data from comm port
      ~comm();              // destructor
};

===== File : RS232.CPP =======================

#include "rs232.hpp"

// Initial RS232 & set IRQ ISR
comm :: comm(int port_no,int baud,char parity=0,char length=8,char stop_bit=0)
{
         :
         :
         :

    // Set 8259 peripheral interrupt controller
    OldIRQ = getvect(com_irq[port]);    // get old IRQ ISR
    setvect(com_irq[port],&comm::NewIRQ);      // set new IRQ ISR
         :                ^^^|^^^^^^^^^
         :                   V
                   Error : Connot convert 'void (far interrupt comm::*)()'
                           to 'void (interrupt far *)(...)'
}

// New IQR interrupt service routine
void interrupt comm :: NewIRQ()
{
         :
         :
}
         :
         :
         :
main()
{
    comm rs232(1,BAUD_115200);          // Initial RS232
    rs232.send('A');
    return 0;
}


Newsgroups: comp.lang.c++
From: steve@taumet.com (Steve Clamage)
Subject: Re: using (...) question
Organization: TauMetric Corporation
Distribution: usa
Date: Mon, 17 Aug 1992 17:07:33 GMT

pjl@sparc10.cs.uiuc.edu (Paul Lucas) writes:

>In <J3mkPB8w165w@toz.buffalo.ny.us> cyberman@toz.buffalo.ny.us (Cyberman) writes:

>>I know printf is prototyped as
>>int printf(char *,...);
>>I would like to know how from within the function to access the 
>>remaing parameters!

>*****>	By using <varargs.h>  Stroustrup, 2nd. edition, has an example as
>	does my book.

The usual C implementations of <varargs.h> are not usable in C++, as
the macros result in illegal C++ code.

The Standard C header file <stdarg.h> serves the same purpose and is
generally available with C++ implementations.  The ANSI/ISO C++
committee has voted to make the Standard C header <stdarg.h> part of C++.

If at all possible, you should use <stdarg.h> rather than <varargs.h>.
See any good Standard C text for information on the use of these macros.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Vice Chair, ANSI C++ Committee, X3J16
Newsgroups: comp.lang.c++
From: jimad@microsoft.com (Jim Adcock)
Subject: Re: Language extension
Date: 18 Aug 92 00:46:03 GMT
Organization: Microsoft Corporation

In article <memo.575428@cix.compulink.co.uk> vadim@cix.compulink.co.uk writes:
| #for f in  #methods(T) 
|  #if f == T::T  && #visibility(f) == public
|   Constrained(#arglist(f)) : T(#params()) { check(); }
|  #endif
| #endfor
|};
|
|Actually the TI  C++ Preprocessor has somewhat similar capabilities,
|but it is limited by fact that it is a PREPROCESSOR, and does not
|have full access to all compiler data structures.
|
|What do you think?

Some ideas:

* C++ currently has *two* "preprocessors" -- one is the historical
#ifdef #endif #gunk from "C" prehistory, the other is the "preprocessing"
implied by templates.  We should head away from the "C" #gunk and move
towards better "template" capabilities instead.  Current template proposal
is simply much too weak.

* Given better preprocessing, you still have to be able to use the "built-in"
syntax of the language to perform your "enhanced" functionality, or people
simply won't use it.  For example:

	GCed_pointer<foo> pfoo = new Foo;

is not acceptable to "real world" programmers.  It must be possible to have the
"GC'ed"-ness associate with Foo [actually, with a base class of Foo] and
then allow classes to override the built-in behavior of ALL the aspects of
that class, including pointers and references, such that the end programmer
just writes:

	Foo* pfoo = new Foo;

and pfoo is automatically a GC'ed pointer.

* IF you can accomplish these tasks -- namely seamlessly add functionality
to the language, then the next problem that you find is that C++ code 
optimizers are not up to the task.  This problem in turn is to a large extent
due to problems of uncontrolled and undefined aliasing in C++, which prevents
code generaters for coming up with reasonable code -- especially in the case
of "simple" objects such as smart pointers.


Newsgroups: comp.lang.c++
Newsgroups: comp.lang.c++

Can someone please help me with a strange problem in Borland C++?

Defining a class' constructor with arguments has affected compilation of
operator overloading friend functions. In the following program, there
are two class definitions for Header. The first one, (without argument
to the constructor) compiles successfully. The second one, (with argument
int i to the constructor) results in two errors at compile time, in
overloaded operator function definitions ifstream& operator>>() and
ofstream& operator<<().


The following program was compiled using Borland C++ version 3.1.
The source code has been edited for readability. Ignore the warnings
and look out for the following 2 errors.

Error 1: Ambiguity between 'operator >>(ifstream &, Header &)' and
				'istream::operator >>(unsigned char &)'
Error 2: Ambiguity between 'operator >>(ofstream &, Header &)' and
				'ostream::operator >>(unsigned char &)'




/********************	START OF SOURCE CODE	*********************/
#include <string.h>
#include <fstream.h>
#include <iostream.h>


/* CLASS DEFINITION WITHOUT ERROR - NOTICE NO ARGUMENT TO CONSTRUCTOR*/
/*class Header
	{
	public:
		Header();			//constructor to init all above fields
		friend ifstream& operator>>(ifstream& ifs, Header& hdr);
		friend ofstream& operator<<(ofstream& ofs, Header& hdr);
	};

Header::Header()
	{
	}
*/


/*****CLASS DEFINITION CAUSING ERROR - NOTICE ARGUMENT TO CONSTRUCTOR *****/
class Header
	{
	public:
		Header(int);
		friend ifstream& operator>>(ifstream& ifs, Header& hdr);
		friend ofstream& operator<<(ofstream& ofs, Header& hdr);
	};

Header::Header(int i)
	{
	};



ifstream& operator>>(ifstream& ifs, Header& hdr)
	{
	char empty;
	ifs >> empty;
	return (ifs);
	};

ofstream& operator<<(ofstream& ofs, Header& hdr)
	{
	char empty = '@';
	ofs << empty;
	return (ofs);
	};
/*******************	END OF SOURCE CODE	*************************/

Xref: sparky comp.lang.c++:12428 comp.object:3228 comp.databases:6155