HDTenEightyP/NetNews huggingface dataset:
From: paul@hp4at.eunet.co.at (Paul Gillingwater)
Subject: va_arg() with Zortech's C++ compiler strangeness
Organization: EUnet EDV Dienstleistungs GmbH A-1010 Wien Austria
Date: Wed, 23 Dec 1992 22:00:33 GMT

I'm using Zortech's C++ compiler version 2.1, although this segment of 
code is written in C.  I seem to get a syntax error when I change from 
the default (small) memory model, to the C (compact) memory model.

ztc -I.. -mc -b -p -c -DDOS -DANSI _VSSCANF
ztc1b -I.. -mc -p -DDOS -DANSI -oC:\WINDOWS\TMP\ztc_JC7.tmp _VSSCANF
                char_ptr = va_arg (arg_ptr, char far*);
                                                    ^
"_VSSCANF.c", line 132 Syntax error: lvalue expected
                char_ptr = va_arg (arg_ptr, char *);
                                                 ^
"_VSSCANF.c", line 194 Syntax error: lvalue expected

As you can see, I tried changing the pointer to a far pointer, which I 
is necessary to access objects outside the 64kb data segment.  I under-
stand that the C model supports a 64 kb code space and a 1 Mb data space.
This code compiles just fine when compiled using S (small) model.
BTW, the code is taken from the PDCurses library, which was posted to
comp.sources.misc this month.  I have it mostly working with the Zortech
compiler, except for delay_output() and this memory model.

This code segment then uses va_arg, which is a macro defined thus in 
stdarg.h:

#define va_arg(ap,type)	(*((type __ss *)(ap))++)

As you can see, the macro uses a type of __ss *.  I tried this, with
the same result.  Is this due to my limited understanding of variable
argument macro implementations, or something flakey in Zortech's compiler?

Please mail responses to me, as I don't have much time to read posts,
and I'll summarize if there is interest.
-- 
Paul Gillingwater
Home system: paul@actrix.co.at (Waffle)
Newsgroups: comp.lang.c
From: stasica@alumni.cs.colorado.edu (The Legacy)
Subject: System Testing
Organization: Damage, Inc.
Date: Mon, 21 Dec 1992 17:25:06 GMT


I'll try this again since no one answered it the first time.

I am trying to test system memory, I/O, and CPU.

Here are some very simple, yet intensive busy work routines I have written.
Can someone give me an idea if these are valid at all or should I go about
the algorithm via some other "C" methods:

void memory_test()
{
    int *p, i;
    p=malloc(8388608);       /* Malloc 8M memory */
    for (i=0;i<8388600;i++)  /* Write to all 8M 1 char at a time */
        *(p+i)='\0';  /* BTW this doesn't work....why??? (memory violation)*/
    free(p);
}

void cpu_test()
{
    int i; double d;
    for (i=0;i<30000000;i++)    /* Do a bunch of calculations */
        d=(23423423+2394823/234763287*3276472364/2347632+23876322-123123)/2372;
}
/* Or should I so some other busywork, as this tests FPU's more than CPU */
/* But what kind of busy work?  just loop for 1 billion times?  */

void io_test()
{
    int i; char c; FILE *tmp;
    tmp=fopen("tmp$$$.tmp","w");            
    for (i=0;i<FILECHARS;i++) putc('a',tmp);     /* Write chars to a file */
    fclose(tmp);
    tmp=fopen("tmp$$$.tmp","r");
    for (i=0;i<51200;i++) c=getc(tmp);           /* Read chars from a file */
    fclose(tmp);
}

All these tests take a certain amount of time (around 10 secs each on my
system).  Are these all good or is there too much overhead in either "C"
or basic system architecture to make these busywork tests invalid?
-- 
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* "What do you mean I don't get to work on time... got nothing better to do." *
* "What do you mean I don't pay my bills... why do you think I'm so broke?"   *
*                       stasica@alumni.cs.Colorado.EDU                        *
Newsgroups: comp.lang.c
From: ecm@casbah.acns.nwu.edu (Edward Malthouse)
Subject: integer overflow
Organization: Northwestern University, Evanston Illinois.
Date: Sat, 26 Dec 1992 18:49:54 GMT

Is there any way of checking for overflows when doing integer arithmetic?

For example, suppose my compiler uses 2 byte short int's and I multiply two
short int's and place the result in another short int but the product is 
greater than 2^15.  Clearly the result will not be what I want.

Thank you in advance for your help.  Please e-mail responses and I will
summarize if there is interest.

Ed Malthouse
From: jfw@ksr.com (John F. Woods)
Newsgroups: comp.lang.c
Subject: Re: Question to test general C knowledge
Date: 22 Dec 92 14:36:52 EST

volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe) writes:
>No, you're missing the point. Real compilers don't go out of their way 
>to take advantage of undefined behavior and cause trouble.

Real compilers often cause trouble without going out of their way.
Real good programmers don't go out of their way to take advantage of
undefined behavior just because all six copies of Microsoft C give the
same results.


>However, I also raised an issue concerning
>whether or not the expression *really* violates the shall-rule in
>3.3, and that depends on the definition of the term "modify" as used
>in section 3.3. As far as I can tell, no one has commented on that issue
>yet.

I asked Doug Gwyn.  He concurred that "x = ++x;" falls under the restriction;
"modify" does not mean "changed" in that context, just as it does not in
several other contexts in the standard:

	const int i = 4;
	int *ip = (int *)&i;

	*ip = 4;

I hope you agree that this is undefined.  Doug is not the ANSI Committee, of
course, so if you want a definitive ruling, you can submit an RFI.
From: fischer@iesd.auc.dk (Lars Peter Fischer)
Newsgroups: comp.lang.c
Subject: Re: A good book on C ?
Date: 30 Dec 92 19:08:43 GMT
Organization: Mathematics and Computer Science, Aalborg University


>>>>> "William" == William J. Bene (wjb@cscsun2.larc.nasa.gov)

William> Other than K&R, are there any other C reference manuals that
William> anyone cares to recommend?

Well, someone already pointed out Harbison and Steele (be sure to get
the 3rd edition), but be sure to get

  Andrew Koenig: C Traps and Pitfalls, Addison-Wesley, 1989,
  ISBN 0-201-17928-8

It's a real gem. Brief and to the point, a delight to read, with lots
of good points on how to use C effectively, on programming style, and
on programming in general.

Also 
  
  P. J. Plauger: The Standard C Library, Prentice-Hall. 1991,
  ISBN 13-131509-9

is worth some serious consideration.

/Lars
--
Lars Fischer, fischer@iesd.auc.dk | It takes an uncommon mind to think of
CS Dept., Aalborg Univ., DENMARK. | these things.  -- Calvin
From: kdq@quest.UUCP (Kevin D. Quitt)
Newsgroups: comp.lang.c
Subject: Re: System Testing
Date: Tue, 22 Dec 92 17:58:08 PST
Reply-To: srhqla!quest!kdq
Organization: Job quest  (805) 251-8210,  So Cal: (800) 400-8210

stasica@alumni.cs.colorado.edu (The Legacy) writes:
> 
> void memory_test()
> {
>     int *p, i;
>     p=malloc(8388608);       /* Malloc 8M memory */
>     for (i=0;i<8388600;i++)  /* Write to all 8M 1 char at a time */
>         *(p+i)='\0';  /* BTW this doesn't work....why??? (memory violation)*/

    Perhaps because p is a null pointer?  You should always check the
return from malloc.

> void cpu_test()
> {
>     int i; double d;
>     for (i=0;i<30000000;i++)    /* Do a bunch of calculations */
>         d=(23423423+2394823/234763287*3276472364/2347632+23876322-123123)/237

    Any compiler worth its salt will reduce this loop to no code at
all.  It you're going to do this, try something like d += (double)i++;
Of course, a REALLY clever compiler could replace that with

	d = 30000000 * 30000001 / 2;

    and then just generate the single assignment, or drop it altogether.


    If you want to benchmark your system, you should examine some of
the standard benchmark programs, like whetstone and dhrystone to see
what they do to overcome compiler cleverness.  Also important to
remember is that benchmarks are of little meaning if the computers are
significantly different in architecture; even comparing between 68000s
and 68020s can lead to some bogus results (with the 68000 coming in
ahead!).  If you can't find anything you like at simtel, send me a
note and I'll ship you my collection.


 _
Kevin D. Quitt      96.37% of all statistics are made up.     srhqla!quest!kdq
From: lord@tradent.wimsey.bc.ca (Jason Cooper)
Newsgroups: comp.lang.c
Subject: ** HELP WITH FILE I/O **
Date: Sat, 02 Jan 93 22:02:18 PST
Organization: TradeNET International Trade Corp.

Eeek!  I am writing a program to handle a local track meet and have to 
input the participant records from a file.  What I want to do is load 
these into an array for quick and easy access.  The array is right now of 
undefined length, and its elements are structures (including each event, 
it's heat, it's event, etc.).  I've tried using:

fread(meet[record], sizeof(struct meetstruct), 1, tfile)

Where meet is the array, meetstruct is the structure the array is 
composed of, and tfile is the track meet's file stream.  I don't know 
_what_ I'm doing wrong, but if somebody could correct this (oops, forgot 
to mention, that's in a loop to go through records, I tried taking the 
whole thing in one, but that didn't work either), then I'd appreciate 
that VERY MUCH.  If I could input the whole thing in one with fread or 
something, that would be _WONDERFUL_.  I'm using Borland C++, and would 
like to understand _what_ I'm doing, so if you could explain it too, that 
would be nice.  If I have to limit the size of the array, that's doable 
too.

                                                Jason Cooper

Oh, and, since I'm being less-than-coherent, if you think you can help me 
but are not sure, PLEASE send me private mail...

/d
(oops)
Newsgroups: comp.lang.c
From: mitch@nosc.mil (Ray Mitchell)
Subject: Scanf field width macro?
Organization: Naval Ocean Systems Center, San Diego, CA
Date: Mon, 28 Dec 1992 21:31:29 GMT


Consider the statements

   printf("%*s", field_width, char_buffer);
    scanf("%5s", char_buffer);

I would like to avoid embedding the magic field width constant in the
scanf.  I don't need it to be a variable field width like in printf
but only need it to be in terms of some constant width macro I've
previously defined.  I've tried various things using stringization,
token pasting, etc. to no avail.  A solution which does not depend
on some non-standard preprocessor/compiler behavior is required.

Thanks,
Ray Mitchell
mitch@nosc.mil
Newsgroups: comp.lang.c
From: Mike Erwin <erwin#m#_mike.ast_-_tac_mail_server@msgate.corp.apple.com>
Subject: Survey:  Commercial Libraries (Your favourites, opinions, et al)
X-Useragent: Nuntius v1.1.1d9
Date: Wed, 30 Dec 1992 19:09:08 GMT
X-Xxdate: Wed, 30 Dec 92 13:07:04 GMT
Organization: Apple Computer, Inc.


	How many of you use commercial libraries?  What type of functionality do you
need from them mostly?  Would you rather program low level junk yourself? 
Which ones do you consider the best/worst?  Are they even at all useful, or
are they a waste of time and money?

Your opinions, comments and grumbles are welcome.
|  "From the lightning in the sky, as it passed me flying by,
|   From the thunder and the storm, and the cloud that took the form,
|   (When the rest of heaven was blue), of a demon in my view." 
|       {10010 | 0111}  ? Veritas Aut Nihil! ? Heads- heads... heads?  heads!
| 
|  Mike Erwin,       UNIX Systems Administrator       Apple Computer, Inc.   
 
|  erwin#m#_mike.ast_-_tac_mail_server@msgate.corp.apple.com
|    Apple: 512-919-2223      TT: 512-345-3573
Newsgroups: comp.lang.c
From: burr@seas.gwu.edu (Timothy J. Burr)
Subject: Compiling ANSI C on Sun4's
Organization: George Washington University
Distribution: usa
Date: Wed, 30 Dec 1992 15:07:40 GMT

I'm trying to compile the renderer to run on the suns, but I'm having
trouble.  All my code is in ANSI C, and the cc command doesn't like
it.  I tried gcc, but that give me errors relating to the stdlib.h
files and such, which aren't even mine.  Anybody know how I can compile
ANSI C on the sun4's with a minimum of pain?  

Thanks,
Tim


burr@seas.gwu.edu      -      burr@enews.nrl.navy.mil
From: roy%cybrspc@cs.umn.edu (Roy M. Silvernail)
Newsgroups: comp.lang.c
Subject: Re: Float point format not loaded?
Date: Mon, 28 Dec 92 19:12:46 CST
Organization: Villa CyberSpace, Minneapolis, MN

mccall@mksol.dseg.ti.com (fred j mccall 575-3539) writes:

> In <1he75eINNmlg@uwm.edu> pegasus@csd4.csd.uwm.edu (David R Hucke) writes:
> 
> >I am having a problem with Turbo C 2.0.
> 
> >I am writing a program that does some float calculations and when I run the
> >program I get a run-time error saying:  Floating point formats not loaded.
> >Abnormal termination.
> 
> Try DOING something with the fp variable that you declared (assign to
> it or something).  Otherwise, the floating point libraries don't get
> linked in.

What you really need to do is some floating-point math.  In my
experience, simple assignments don't count as float math.  I just
put 'exp(1.0);' in the early part of main(), and the problem disappears.

One might think Borland would have fixed this, by now.  But I hear that
the bug persists into Borland C++ 3.0.
--
Roy M. Silvernail --    [my machine ] "Sometimes, you're the windshield....
roy%cybrspc@cs.umn.edu  [my opinions]            sometimes, you're the bug!"
cybrspc!roy@cs.umn.edu  [my $0.0275 ]                      --Mark Knopfler
From: david@rex.uokhsc.edu (David W. Bourne)
Newsgroups: comp.lang.c
Subject: upper/lower case with VMS C
Date: 24 Dec 92 18:58:04 GMT
Organization: Health Sciences Center, University of Oklahoma

I am trying to compile a 'c' program I obtained from a colleague under
VAX VMS. With other module I had no real problems but one module
apparently has variables with the 'same' names, that is only case
different.

One line reads

  double *Ao, *Ak, .... , *ao

I then get an error message CONFLICTDECL indicating that the ao is
a redeclaration of the Ao variable.

I have tried the compiler switch /NAME=AS_IS without success.

Also I tried to use the VAXCRTL_FOR_NAS.OLB library without success.

I have been able to compile the module on a UNIX machine without a problem.
It seems to be the VAX VMC 'c' environment that is causing a problem.

Any suggestion, Thanks, David Bourne, david-bourne@uokhsc.edu
From: torek@horse.ee.lbl.gov (Chris Torek)
Newsgroups: comp.lang.c
Subject: Re: String function names
Date: 31 Dec 1992 23:41:02 GMT
Organization: Lawrence Berkeley Laboratory, Berkeley CA
NNTP-Posting-Host: 128.3.112.15

Some time ago, in article <alien.01il@acheron.amigans.gen.nz>
Ross Smith (alien@acheron.amigans.gen.nz) asked:
>>Out of curiosity, does anyone know the derivation of the names of the more
>>obscure string functions? Names like "strcat()" and "strlen()" are obvious
>>enough, but what on earth are "strcspn()", "strpbrk()", and "strspn()"
>>supposed to mean?

In article <1992Dec31.142013.21895@stsci.edu> kimball@stsci.edu
(Timothy Kimball) writes:
>You got me.  And if you look on page 388 of Plauger,
>_The_C_Standard_Library_, you'll see that he's mystified by it, too-
>and he sits on the ANSI standards committees!

Someone else posted some guesses, but I think mine are closer. :-)

	strspn:	span (extend across) characters in a set, hence
		`STRing SPaN'
	strcspn: span characters in the complement of a set, hence
		`STRing Complement SPaN'

Strcoll() comes from `collate' (`assemble and arrange systematically'
or `compare').  Strpbrk() is something of a puzzle; the best I can come
up with is `point to break character' (from a set of break characters):
e.g., one might find white space for token-making using

	p = strpbrk(str, " \t\n");

Strstr() and strtok() are fairly stragihtforward (STRing subSTRing and
STRing TOKen).  Strxfrm() is `STRing transFoRM', with x replacing
`trans'.  Except for memmove, strcoll, strerror, and strxfrm---all ANSI
C inventions---the new functions entered C via System III UNIX, the
same people who brought you the wretched SysV IPC and shared memory.
That would explain both the peculiar set of operations (why both
strpbrk and strtok; why is strtok not reentrant; and why have strpbrk
and strcspn, which are complementary---strpbrk(a,b) is much like
a+strcspn(a,b)---without a complement for strspn?) and the inexplicable
names, all in one swell foop.
-- 
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
From: behrenss@Informatik.TU-Muenchen.DE (Soenke Behrens)
Subject: Re: stderr: Question
Keywords: fprintf stderr
Organization: Technische Universitaet Muenchen, Germany
Date: Tue, 22 Dec 1992 16:00:51 GMT

caliaro@avalon.physik.unizh.ch (Aurelio Caliaro) writes:

>I would like to redirect all output made by "fprintf(stderr, ...)" to a
>procedure. Is that possible without changing the source everytime that
>stderr comes? Maybe a #define?

Pardon? What exactly do you mean by "redirect output to a procedure"?
Sounds more than strange ... :)

Soenke
-- 
===========================================================================
More than silver, more than gold, I need   !    behrenss@informatik.
electricity. I need it for my dreams.      !    tu-muenchen.de
(RACTER)                                   !  FIDO: 2:246/13 Soenke Behrens
From: tjhendry@mcs.drexel.edu (Jonathan Hendry)
Newsgroups: comp.lang.c
Subject: strtok
Date: 31 Dec 92 04:59:02 GMT
Distribution: usa
Organization: Drexel University

Hi. Could someone please email me a brief description of how to use
strtok()? I have read a few books, and asked my coworkers, and haven't
received much useful information.

Namely, after I run it on a string once, how do I get to the next
part of the string?

Thanks!

Jonathan Hendry

-- 
Jonathan W. Hendry
Drexel University College Of Information Studies
Anderson Financial Systems "Programmer-in-Exile" :)
hendryjw@duvm.ocs.drexel.edu (No NEXTMail :( )
Newsgroups: comp.lang.c
From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
Subject: Re: Question to test general C knowledge
Organization: Texas Instruments Inc
Date: Mon, 28 Dec 1992 16:17:30 GMT

In <wsP8VB1w165w@quest.UUCP> kdq@quest.UUCP (Kevin D. Quitt) writes:

>mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
>> sizeof(4["this is a test"])
>> must produce 1, or your compiler's broken.

>    Either that, or you've got 16-bit chars.

sizeof(char) is defined to be 1, so it doesn't matter if you have
16-bit chars or not; it still better give back a 1.

-- 
"Insisting on perfect safety is for people who don't have the balls to live
 in the real world."   -- Mary Shafer, NASA Ames Dryden
------------------------------------------------------------------------------
Fred.McCall@dseg.ti.com - I don't speak for others and they don't speak for me.
Newsgroups: comp.lang.c
From: hbf@durin.uio.no (Hallvard B Furuseth)
Subject: Re: assert
Organization: University of Oslo, Norway
Date: Mon, 21 Dec 1992 18:38:32 GMT

In article <1992Dec21.163006.8068@taumet.com> steve@taumet.com (Steve Clamage) writes:

>>assert is sometimes (ie sun or gcc) defined to call another macro (ie
>>__assert) which does most or all of the work.  I expect it's a hack to
>>make sure the argument is stringified properly, or something like that.
>>Can somebody explain?
>--
>
> It is probably invoking a function rather than another macro.

Yes, then I would understand.  But look at this, from sun4os4.1:

# define _assert(ex)	{if (!(ex)){(void)fprintf(stderr,"Assertion failed: file \"%s\", line %d\n", __FILE__, __LINE__);exit(1);}}
# define assert(ex)	_assert(ex)

Or this, from gcc-2.3.2/assert.h (this is the __GNUC__ && !__STDC__
part, the other parts are similar):

extern void __eprintf (); /* Defined in libgcc.a */

#define assert(expression)  \
  ((void) ((expression) ? 0 : __assert (expression, __FILE__, __LINE__)))

#define __assert(expression, file, lineno)  \
  (__eprintf ("%s:%u: failed assertion `%s'\n",		\
	      file, lineno, "expression"), 0)
--

Hallvard
From: gt6758b@prism.gatech.EDU (Michael Maverick Kopack)
Newsgroups: comp.lang.c
Subject: Moving from Pascal to C, Help please!!!!!!
Date: 28 Dec 92 19:22:19 GMT
Organization: Georgia Institute of Technology

Could somebody please tell me how I should go about trying to learn C? I've
gotten SAS/C 6.1, but really don't understand what I'm doing with it. My
programming experience has been limited to PASCAL and BASIC and LISP. Heck,
they don't even teach C here at GT!  I co-op with a government research center
and they have taught me a little, but I'm having a really big problem 
understanding the stuff with pointers.

I have been reading through a book called "C as a second language for PASCAL
programmers" and have the most recent copy of the CManual disks in the Fish
collection printed out. Are there any resources I could use that would give
me a good, solid understanding of C.... I don't care about being able to do all
the wiz-bang graphics and such yet, I just want to be able to write a few
useful programs in C for my Amiga!

There are a lot of things about C that I find very frustrating after comming
from a decent course in Pascal. For one is the way that Arrays are handled.
I like being able to do stuff like    array [6..26] of int whereas in C you
get forced into calling the indeces 0-19. I also HATE that there are no true 
pass by reference parameters! 

It seems that C pretty much took Pascal and threw all the rules out the window!
I can't imbed functions so other procedures can't see them (scoping rules),
I have to use global variables a lot (taught as a no-no at GT) and it just
seems like C is TOO flexible! How do you guys get anything done when there are
about 500 different ways to do it?

Please, open my mind to C! I'd hate to have to try to do everything for my 
Amiga in Pascal, considering how much of the Amiga software is written in 
and documented for C......

Thanks a million,
Mike Kopack
-- 
Michael Maverick Kopack                | Sex, drugs, rock and roll  
Internet: gt6758b@prism.gatech.edu     |and my Amiga, what else could
          kopack@vortex.erda.rl.af.mil |one ever want?     
          kopackm@lonex.rl.af.mil      \---------------------------------------
Newsgroups: comp.lang.c
From: dkeisen@leland.Stanford.EDU (Dave Eisen)
Subject: Re: Any hope for me..?
Organization: Sequoia Peripherals, Inc.
Date: Sun, 3 Jan 93 01:59:36 GMT

In article <1993Jan2.215528.1@npe.isnet.inmos.co.uk> adcrumpler@npe.isnet.inmos.co.uk writes:

>
>What I'd like to know is:-  What range of academic qualifications
>do the various contributors possess ?  And can I, who didnt really
>make the most of his schooldays, hope to attain similar levels
>of knowledge and competence as you all possess ?

Academic qualifications are not real important for programming. I
have all kinds of academic qualifications, none of which are in
CS or engineering. I learned all I know about C, UNIX, programming,
and the rest of CS by reading books, having a job which forced me 
to learn a little bit, reading the net, and sitting in on a few courses.

I had no problems finding a job despite the fact that my qualifications
were in another discipline (theoretical Mathematics), but I understand
that times have changed and employers are looking more specifically
for CS majors than they were a few years ago. I don't know --- when I
have to hire I look for smart people and I figure they can learn
whatever they need to learn, but I think our company is in the minority
here.

So Learn what you can. The net is a fabulous resource. Read books
on a wide range of CS topics. And go out and do something. Employers
are much more concerned with what kinds of projects you've worked
on and the level of responsibilities you had on these projects. They're
even more impressed if these projects made someone some money. So
I guess your lack of academic credentials will make it harder for
you to get your foot in the door at your first programming job, but
if you work your tail off and do a good job, they shouldn't handicap
you for more than a year or so.

Good luck finding work.



-- 
Dave Eisen                               Sequoia Peripherals: (415) 967-5644
dkeisen@leland.Stanford.EDU              Home:                (415) 321-5154
       There's something in my library to offend everybody. 
          --- Washington Coalition Against Censorship
Newsgroups: comp.lang.c