HDTenEightyP/NetNews huggingface dataset:
From: torek@horse.ee.lbl.gov (Chris Torek)
Newsgroups: comp.lang.c,comp.std.c
Subject: Re:  can a pointer cast to a void* be compared to (void*)0 ?
Followup-To: comp.std.c
Date: 22 Jan 1993 10:34:25 GMT
Organization: Lawrence Berkeley Laboratory, Berkeley CA
NNTP-Posting-Host: 128.3.112.15

In article <alien.02pi@acheron.amigans.gen.nz> alien@acheron.amigans.gen.nz
(Ross Smith) writes:
>Now a couple of questions of my own. I know (or think I know) that the
>standard does not require pointers to functions to be castable to/from any
>other pointer type.

Yes (or rather, the effect is undefined or unspecified or otherwise
left dangling).  (I should go dig out my ANSI C standard box and unpack
it someday :-) )

>(1) Are pointers to different types of function required to be castable to
>each other?

Yes; however, the result is up to the implementation.  Your only guaranteee
is that if the result is then cast *back* to the `correct' type, you
get back the original pointer-to-function.  I know for certain that
the final result can be used to *call* that function; I am somewhat
less certain that it must compare equal to the original pointer.

>(2) If a compiler does allow casting between "ordinary" pointers and function
>pointers, does the rule about null pointers remaining null still apply?

(By `ordinary' I assume you mean `data' or `object' pointers.)
It does not, so the, ah, point, is moot.

Note, however, that the null pointer constant can be cast or assigned
to a type of the form `pointer to function ...'; the result is a null
pointer of that type, which should compare equal to another null pointer
constant.

Another question (which belongs in comp.std.c; note followup header):
do null pointer constants, cast or assigned to pointers to functions
of different types, then to a common type, compare equal?  For instance:

	typedef int (*f1)(int);		/* function type #1, e.g., abs */
	typedef double (*f2)(double);	/* function type #2, e.g., sin */
	typedef void (*f3)(void);	/* function type #3 */

	f1 a;
	f2 b;

	a = NULL;
	b = NULL;

	(f2)a == b	/* must this give 1? */
	(f3)a == (f3)b	/* how about this? (should be the same, I imagine) */
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)
Berkeley, CA		Domain:	torek@ee.lbl.gov
Newsgroups: comp.lang.c,comp.lang.c++
From: erc@netcom.com (Eric Smith)
Subject: Re: C/C++ Correctness (was: Re: C/C++ Speed)
Organization: Netcom - Online Communication Services (408 241-9760 guest)
Date: Thu, 21 Jan 1993 08:15:37 GMT

In article <1jkismINN3qq@armory.centerline.com> jimf@centerline.com (Jim Frost) writes:
...
>It's true that if you use C++ as a C with better type checking there
>will be few runtime performance penalties.  In fact, C++ inlining
>alone can overcome many performance drawbacks.

That implies that C++ has performance drawbacks to overcome, but there
are none except when using specific non-C features of C++ which are easy
to avoid, if avoiding them is desired.

Inlining can in fact make C++ faster than C, especially if it's the
only non-C feature you use in C++.  For many C programmers, inlining
alone is enough to justify the move to C++.

The way to make inlining effective is to use it carefully, and only
inline the most critical speed sensitive functions.  If you inline
functions that don't really need it, you pay a penalty in size of your
executable program, which can also cause virtual memory paging, which
can slow the whole program down and defeat the whole purpose of
inlining.  But using it just for your most critical speed sensitive
functions could in some cases make your program run significantly
faster, depending on just how speed sensitive those functions are.
Xref: sparky comp.lang.c:20028 comp.lang.c++:19695
From: jimf@centerline.com (Jim Frost)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: Graphics
Date: 21 Jan 1993 20:31:01 GMT
Organization: CenterLine Software, Inc.
NNTP-Posting-Host: 140.239.3.202

learman@cps.msu.edu (Jerome M Learman) writes:
>I what to do some graphical programming and I want to get some comments on a 
>couple of things. I want to you high quality graphics VGA or SVGA.

Hmm, VGA and SVGA are hardly what I'd call high quality, but then
again I'm a snob :-).

>What is best to use for portabilty between unix and ibm compatablies?

There are very few graphics packages that are portable between them (I
know of none I'd recommend).  What I've done in the past to handle
graphics portability is to write my own graphics description layer and
then port *that*.  Depending on what you need it can be a lot of work
though.

In a previous life I wrote a "portable" object-based graphics library
under X11 that myself and a co-worker ported to SGI GL in about a day
and tuned in a week.  That library was rather complicated (it
supported object collision detection and multiple overlays in software
along with a healty supply of graphics primitives and extremely
efficient repainting) and it took some months to write and debug, but
simpler drawing libraries wouldn't be so hard.  If you keep the
necessary primitives to a minimum the porting task isn't too hard, as
demonstrated by the fact that we ported our library so quickly.

Without a set of graphics primitives for DOS machines it would be a
big hassle, though.

>I have use Xview for but I believe this is exclusive to X windows.

Xview is based on SunView and it's rather primitive.  It's good for
simple applications but isn't particularly good for anything more
complicated.  It's certainly not the least bit portable.

>What is exactly is motiff?

Motif is a look-and-feel specification.  There's a library that
implements a bunch of Xt widgets which implement the Motif
specification that's also commonly called "Motif."  It's not portable
either and it doesn't implement generic graphics commands.

>What did the best way to create motion?

There are a couple of "best" ways, depending on what you're working
with and what you need to do.  The most generic way is to
double-buffer -- you set the display up with two frame buffers, draw
on the one that's not visible, then make it visible while you draw on
the other one.  Most good graphics hardware has double-buffering
capability, but almost no X servers support this capability and I
don't think VGA/SVGA does either.  Without double-buffering the best
you can do is to draw onto an area that's not in the frame buffer (an
X Pixmap or an area in memory, for instance) and then blit it onto the
display.  If the object's not very big and you limit your blit to the
size of the object it'll work fairly well.  Given the limited
resolution of SVGA I think it'd work quite well.

There are a lot of other techniques for accomplishing animation that
aren't as general; if you're really interested in the topic you should
hit your local library for some books.

jim frost
jimf@centerline.com
Newsgroups: comp.lang.c,comp.lang.fortran
From: michael@chpc.utexas.edu (Michael Lemke)
Subject: Re: calling a Fortran subroutine from a C program
Organization: The University of Texas System - CHPC
Date: Sat, 23 Jan 93 05:30:42 GMT

In article <1993Jan23.025835.16538@sol.ctr.columbia.edu> bobp@msi.com (Bob Pitha) writes:
>Michael Lemke (michael@chpc.utexas.edu) wrote:
>: To make it really clear:  The difference is
>
>: 	CHARACTER*100 STRING
>
>: or
>
>: 	CHARACTER*1 STRING(100)
>
>: which are very different data structures.   The latter is an array, the
>: first is a single variable.  I don't care how C chews its memory, it can
>: hardly distinguish these two cases.  The last is pretty close in
>: functionality to C's concept (except for having a length stored
>: somewhere) as you'd need something like strcpy to copy data.
>
>  Of course they're different in FOrtran; you could hardly do the
>following:
>      character*1 string (100)
>
>      string = "blahblahblah"
>
>  But that wasn't my point.  My point was, I was talking about passing
>an *array or characters* from C.  Rather than write "array or characters"
                          ^^^^
Alright, then your definition is ok.  

>I wrote "character array"; but I was not talking about a Fortran array
>of strings.  

But I also recall you talked about Fortran blank-filling character
arrays.

>I read the question origianlly in comp.lang.c, and in c
>the ambiguity does not exist.  I'm sorry if I confused you.  I think
>we both know what I meant and what you mean, so let's just leave it.

Yes, we do.  I was only concerned about those people who read this and 
will become confused.

Michael
-- 
Michael Lemke
Astronomy, UT Austin, Texas
(michael@io.as.utexas.edu or UTSPAN::UTADNX::IO::MICHAEL [SPAN])
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.c
Subject: Re: Few simple questions
Date: 23 Jan 93 13:05:25 GMT
Organization: AND Software BV Rotterdam

In article <1993Jan22.225219.18959@ringer.cs.utsa.edu> pnarsipu@ringer.cs.utsa.edu (Praasad Y. Narsipur) writes:
|In article <1993Jan21.001022.46578@kuhub.cc.ukans.edu> kugold@kuhub.cc.ukans.edu writes:
|>
|>3. In C again, I want to initialize and array of integers, like
|>   
|>   main()
|>   {
|>     int ttime[6]={0,0,0,0,0,0}
|>     /* rest of program */
|>   }
|>
|>ccom: Error: tr.c, line 12: no automatic aggregate initialization
|>        int     ttime[6]={0,0,0,0,0,0};
|>      ------------------^
|>      ---------------------^
|>      -----------------------^
|>      -------------------------^
|>      ---------------------------^
|>      -----------------------------^
|>ccom: Error: tr.c, line 12: illegal lhs of assignment operator
|>        int     ttime[6]={0,0,0,0,0,0};
|>      -------------------------------^

|This looks perfect. This should probably u would have left something
|in your program. This works for me. 
|Try giving blanks between '0' and `,`.

That's not the issue here. The original poster (more than) probably
uses a pre-ANSI C compiler. Good old K&R1 C doesn't allow initialization
of automatic (or: local) arrays. And that's exactly what the compiler
tells us (see above.) The compiler used above is a very silly compiler
though, because it can signal a _semantic_ error (initialization of
automatic arrays,) while there still is nothing wrong with the _syntax_
of this particular program fragment. The compiler should have been
capable of parsing the entire initializer (and ignoring it semantically)
and start generating code again after the first semicolon. This compiler
chose to do otherwise: it tried to convert the (illegal) initialization
into some sort of assignment and goofed completely by emitting six (!)
errors, one for every initializer. This, of course, causes a lot of
confusion ...

kind regards,

Jos aka jos@and.nl
From: misar@rbg.informatik.th-darmstadt.de (Walter Misar)
Newsgroups: comp.lang.c
Subject: Re: Unknown library call info wanted.
Date: 21 Jan 1993 17:38:18 GMT
Organization: TH Darmstadt
Distribution: world
NNTP-Posting-Host: rbhp61.rbg.informatik.th-darmstadt.de

In article <1993Jan19.164340.3547@frog.CRDS.COM>, miket@frog.CRDS.COM (Michael C Tiernan) writes:
> 
> 	This seems to be the most appropriate place for this so here
> 	goes.
> 
> 	I've got a piece of PD code which is fine EXCEPT for one library
> 	call:
> 		"dist = copysign(d2 / argp->intervals, argp->distg)"
> 
> 	Does anyone out there know what 'copysign' does specifically?
> 	I can assume what it does but I'd like to get a really specific
> 	description maybe in the form of a manual page from some system
> 	so I can write a substitute for it.

I found it in a manpage on a sun4:
> #include <math.h>
....
> double copysign(x,y)
> double x, y;
....
> copysign(x,y) returns x with y's sign bit.

double copysign(double x, double y)
{ if (y>=0) return fabs(x);
  else return -fabs(x);
}

should do as a replacemant.

-- 
Walter Misar                                | It is impossible to enjoy
misar@rbg.informatik.th-darmstadt.de        | idling thoroughly unless
                                            | one has plenty of work to do.
Xref: sparky comp.lang.c:20222 comp.lang.fortran:5188
From: ig25@fg30.rz.uni-karlsruhe.de (Thomas Koenig)
Newsgroups: comp.lang.c,comp.lang.fortran
Subject: Re: calling a Fortran subroutine from a C program
Date: 26 Jan 93 15:12:09 GMT
Organization: University of Karlsruhe, Germany
Distribution: na
NNTP-Posting-Host: fg30.rz.uni-karlsruhe.de

silvert@biome.bio.ns.ca (Bill Silvert) writes:

>In <1993Jan22.233618.17814@chpc.utexas.edu> michael@chpc.utexas.edu (Michael Lemke) writes:

>>Not quite.  To make it really clear:  The difference is
>>	CHARACTER*100 STRING
>>or
>>	CHARACTER*1 STRING(100)
>>which are very different data structures.   The latter is an array, the
>>first is a single variable.  I don't care how C chews its memory, it can
>>hardly distinguish these two cases.  The last is pretty close in
>>functionality to C's concept (except for having a length stored
>>somewhere) as you'd need something like strcpy to copy data.

>It seems to me that there would be absolutely no difference in memory
>allocation between these two cases, and that they would appear identically
>to a C program.  Thus in terms of passing them to a C program I can't
>see what the difference would be.  The only difference is how the Fortran
>code refers to them.

An implementation might very well choose to start every character
variable on a word boundary, for speed reasons.

      CHARACTER*1 STRING(100)

would then appear to C to be an array of ints, instead of chars.
-- 
Thomas Koenig, ig25@rz.uni-karlsruhe.de, ig25@dkauni2.bitnet
Institut fuer Mechanische Verfahrenstechnik und Mechanik,
Bereich Angewandte Mechanik, Tel: 3758
Newsgroups: comp.lang.c,comp.lang.c++
From: erc@netcom.com (Eric Smith)
Subject: Re: discriminated unions (Re: C/C++ Correctness (was: Re: C/C++ Speed))
Organization: Netcom - Online Communication Services (408 241-9760 guest)
Date: Thu, 21 Jan 1993 07:56:42 GMT

In article <1993Jan21.004105.1335@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
>	Later I can write a breadth first search.
>	I dont have to change anything to write the breadth first search.
>	Its just a global function taking the tree as an argument.

Ok, now I understand.  You want to be able to add functionality to a class
without changing the class itself nor deriving a new version of it.  Your
discriminated unions would be helpful toward that goal, but I still don't
see any overwhelming advantage of that goal.  The only real advantage I can
see is that you don't have to use a new class name for your new version.

Other than cluttering class name space, are there any disadvantages in
deriving new classes to add functionality?
From: scjones@thor.sdrc.com (Larry Jones)
Newsgroups: comp.lang.c
Subject: Re: strtol() return values
Date: 27 Jan 93 14:27:08 GMT

In article <ric.728002623@updike>, ric@updike..sri.com (Richard Steinberger) writes:
> 	strtol() returns a long int when successful.  If a non-numeric
> string is encountered, 0 is returned.  Unfortunately, errno doesn't seem
> to be set.

The second argument to strtol is the address of a pointer which strtol
sets to point to the first character following the converted string.
If, after calling strtol, that pointer is equal to the pointer to the
string you asked strtol to convert, then strtol didn't find a valid
string to convert.  For example:

	#include <stdlib.h>
	char *buf, *endptr;
	long val;
	...
	val = strtol(buf, &endptr, 0);
	if (endptr == buf) { /* buf did not point to a valid string */ }
----
Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
larry.jones@sdrc.com
It seems like once people grow up, they have no idea what's cool. -- Calvin
From: sg0d@ns1.cc.lehigh.edu (STEPHEN R. GILBERT)
Newsgroups: comp.lang.c
Subject: Possible bug in BC 3.1: ellipsis in proto argument list
Date: 24 Jan 93 05:00:36 GMT
Organization: Lehigh University

Forgive me if this is a FAQ (probably isn't) or if this question has
been asked before.

I seem to have found a bug in my Borland C++ 3.1 compiler.  I narrowed
the problem down to the following prototype:

void foo(...)

If the above line is by itself in foo.h and I run:
bcc -P -c foo.h
It compiles without mishap.  If you're wondering: -P is to force a C++
compile and -c is compile to .obj only.

The problem is that if I try to compile without the -P, that is,
compile in regular, standard BC 3.1, I get the error message:
) expected

This is no big deal- I can just compile with the C++ option all the
time, but regular BC should be able to compile a prototype with just
an ellipsis in the argument list without a problem- I think.  I guess
my real question is: Does BC 3.1 have a bug?  My bcc.exe is dated
6-10-92 at 03:10a.  If there is a patch floating around somewhere
could someone let me know where to ftp it from.  I checked simtel20
under the borland directory and I already have all the patches for 3.1
installed that are there.  I'd like to avoid calling Borland if someone
else has already found this problem.

I need to use the prototype as shown above, so changing it in some way
will do me no good.

If you have an answer, email to me would be great.  If this is not
possible for some reason, a post is ok.  I'll check for the answer
over the next couple of days.

Thanks.

Steve Gilbert
sg0d@Lehigh.edu
Newsgroups: comp.lang.c
From: "jeff zeitlin" <jeff.zeitlin@execnet.com>
Subject: si units quiz
Reply-To: "jeff zeitlin" <jeff.zeitlin@execnet.com>
Organization: Executive Networks Information
Distribution: comp
Date: 27 Jan 93 21:26:34 EST

DL::>Here's a quick SI units quiz.  What is the multiplier for each of
  ::>the following prefixes.  For extra credit, what is the symbol
  ::>(be careful, case is significant).

DL::>        atto       1E-18           not sure of symbol
  ::>        centi      1E-2    c
  ::>        deca       1E1     da
  ::>        deci       1E-1    d
  ::>        exa        1E18            not sure of symbol
  ::>        femto      1E-15   f
  ::>        giga       1E9     G
  ::>        hecto      1E2     h
  ::>        kilo       1E3     k
  ::>        mega       1E6     M
  ::>        micro      1E-6    Greek lowercase/script "mu"
  ::>        milli      1E-3    m
  ::>        nano       1E-9    n
  ::>        peta       1E15            not sure of symbol
  ::>        pico       1E-12   p
  ::>        tera       1E12    T
  ::>        yocto                      )I do not believe that these 
  ::>        yotta                      )four actually exist.  Please 
  ::>        zepto                      )cite sources.
  ::>        zetta                      )

  J/
  jeff.zeitlin@execnet.com

 * QMPro 1.01   * I could get off Welfare if I didn't pay so many taxes!
--
Executive Network Information System  (914) 667-4567
International ILink Host
Newsgroups: comp.lang.c,comp.lang.fortran
From: mrl@uai.com (Mark R. Ludwig)
Subject: Re: calling a Fortran subroutine from a C program
Organization: /etc/news/organization
	<1993Jan22.200839.8352@sol.ctr.columbia.edu>
	<1993Jan22.233618.17814@chpc.utexas.edu>
	<1993Jan23.152153.7178@biome.bio.ns.ca> <ig25.728061129@fg30>
Distribution: na
Date: 26 Jan 93 17:13:59

In article <ig25.728061129@fg30> ig25@fg30.rz.uni-karlsruhe.de (Thomas Koenig) writes:

|> An implementation might very well choose to start every character
|> variable on a word boundary, for speed reasons.
|>
|>       CHARACTER*1 STRING(100)
|>
|> would then appear to C to be an array of ints, instead of chars.

No, the 77 standard requires that all characters of an array be
contiguous.  

Below, either of these is required to be the same in terms of being 100
contiguous character cells of memory.

        CHARACTER A*1(100), B*100

On Cray, because the machine is word-addressable, they will allocate
each CHARACTER variable which is not associated with any other
variable (by way of EQUIVALENCE or appearing in COMMON), starting in
its own word.

I'll quote chapter and verse if you don't want to take my word for it.$$
Newsgroups: comp.lang.c
From: steve@taumet.com (Steve Clamage)
Subject: Re: Unwanted float to double conversion in variable length arg lists?
Organization: TauMetric Corporation
Date: Fri, 22 Jan 1993 19:38:16 GMT

dmarer@td2cad.intel.com (Dennis Marer) writes:

>I've got a curious problem when passing floats in a variable length argument
>list...they are automatically converted to doubles, EVEN when I typecast.
>Consider:

>#include <stdarg.h>

>void func(int num,...) {
>    va_list va;
>    float x,y;

>    va_start(va,num);
     ...
>    x = va_arg(va,float);
     ...


The results are undefined if you attempt to use types which undergo
promotion with va_arg.   (ANSI Standard section 4.8.1.2)

When you pass a float value (for example) to a function without a
prototype in scope or as a parameter corresponding to the "...",
the compiler *must* promote it to a double.  This typically has a
different representation than a float, as well as a different size.
If you attempt to retrieve a float from the argument list, you will
get garbage, and likely wrong stack offsets for the remainder of the
arguments.  You must retrieve only the promoted type.

If floats and doubles happened to have the same size and representation
on a given system (not impossible), the code would work.

Alternatively, an implementation might provide pragmas which allow
floats to be passed and retrieved.  I don't know of such an
implementation, and the code would not be portable anyway.

The same applies to short and char types, which are promoted to int
when passed.  You must retrieve them as ints, not as chars or shorts,
to get predictable results.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Newsgroups: comp.lang.c
From: arao@andy.bgsu.edu (Avinash Rao)
Subject: C vs C++
Followup-To: comp.lang.c
Organization: Bowling Green State Univerlity
Date: Thu, 28 Jan 1993 18:59:53 GMT

Hi,
			I have a question.  I have done most of my programming in C.  I am okay
at that.  I was wondering if learning C++ would be a added advantage.  I am
contemplating this coz I cannot decide if I need to take a C++ course or
not.  How big is the difference.  I have never exposed myself to OOP.  I
graduate in Dec 93 and I am also looking at it from the job point of view.
			If someone out there knows what I should do. Please help.
Avinash
arao@andy.bgsu.edu.
Please reply at this address.
Newsgroups: comp.lang.c
From: guapo@cs.columbia.edu (J. Robert Diana)
Subject: Think C or MPW C
Organization: Columbia University Department of Computer Science
Date: Thu, 28 Jan 1993 16:51:51 GMT


I need to know, from people who may have used the programs, which is better
or more reliable, Think C or MPW C.  Also, which is cheaper since cost seems
to be a big problem with this project.  Thanks for any suggestions.

Rob Diana

Newsgroups: comp.lang.c
From: pardee@cs.uiuc.edu (Jason Pardee)
Subject: File manipulation from a program...PLEASE HELP!
Organization: University of Illinois at Urbana-Champaign
Date: Sat, 23 Jan 1993 17:11:34 GMT

i want to know if there is a way to rename a file from a C program.  you know,
the equivalent of the command 'ren ldfilename> <newfilename>'.  is there
such a function in C?  if not,  is there a way to invoke a DOS command from
within a program, meaning, is there a way i can execute the 'ren' command
inside my program?

what i want to do is alter some files but keep the same name for the files.
the only way of doing this with my knowledge is creating a new temporary file,
copying the file i want to alter to the temp file, delete the target file,
then recopy the temp file's contents with the proper changes back to  
a file with the same name as the one i started with.  is this clear?  i hope 
i can get some help on this soon.  thanks in advance.
Newsgroups: comp.lang.c
From: Stuart_John@MENTORG.COM (Stuart John)
Subject: externs with Sun acc ?
Date: Mon, 25 Jan 1993 12:14:39 GMT
Reply-To: Stuart_John@MENTORG.COM
Organization: MGC (UK)
Keywords: 
Followup-To: 

Um, compiling progs with acc on 'my' Sun Sparc,
I didn't bother externing any functions from other
modules but they still got linked fine and used correctly...
Either i'm seeing things or i've been using old Apollo
C compiler for too long ?

-- 
  _
 ( `/_
(_)(_(/   Stuart_John@MENTORG.COM

#include<std.disclaimer>