Sunday, April 18, 2010

comp.lang.c - 21 new messages in 11 topics - digest

comp.lang.c
http://groups.google.com/group/comp.lang.c?hl=en

comp.lang.c@googlegroups.com

Today's topics:

* subroutine in c - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c/t/869294a34ac7f7cc?hl=en
* mostly OT (was Re: In the Matter of Herb Schildt: a Detailed Analysis of "C:
The Complete Nonsense") - 5 messages, 4 authors
http://groups.google.com/group/comp.lang.c/t/caf17fab4e7d8530?hl=en
* pointer - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c/t/a4a35284e41ec5c1?hl=en
* New version 1.8 of UML state machine code generator - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/b88c05c9a32070c5?hl=en
* memset pointer to 0 - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/0844332d363fdb33?hl=en
* How often do you have to work around implementations? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/fa1b08d59fe3d0d0?hl=en
* seebs/schildt - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/0c84debf9a4f144b?hl=en
* adding two hex numbers - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/29688d45a35bc095?hl=en
* cast - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/041a2b73cefbd536?hl=en
* An exercise, regarding the implementation of an "if" - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/e21de5b677e11cbd?hl=en
* C - gets() function implementation help - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/7bd0bc765a2e9603?hl=en

==============================================================================
TOPIC: subroutine in c
http://groups.google.com/group/comp.lang.c/t/869294a34ac7f7cc?hl=en
==============================================================================

== 1 of 3 ==
Date: Sun, Apr 18 2010 11:02 am
From: jt@toerring.de (Jens Thoms Toerring)


rudra <bnrj.rudra@gmail.com> wrote:
> I have 2 subroutine in c(which is ultimately called by fortran):
> $ cat bit_unm.c
> /***********************************************
> This code returns the machine bit
> to the program bitinit
> ***********************************************/
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>

> int operating_system(char *sys) {
> FILE *stream;
> char *sysptr;
> int bit;

This is an uninitialized variable that has some random value.

> sysptr = &sys[0];
> sys[0] = 0x0;

Why do you go through all of this? Using the pointer you
received would do quite well (and setting the first ele-
ment of the array pointed is good for nothing).

> stream = popen("/bin/uname -snm", "r");
> fread(sysptr, 1, 32, stream);

What you read from popen() won't contain a trailing '\0',
so what the caller receives isn't a string (and the caller
has no means of finding out how many characters got read
if the stuff returned by popen() doesn't have a trailing
'\n', e.g. in the case that what '/bin/uname' returnsed
is longer than 32 characters (including the '\n' at the
end). Also please note that popen() (and pclose()) isn't
a standard C function (even though it is declared in
<stdio.h> on POSIX compliant system).

A slightly safer version would be

fscanf( stream, "%31[^\n]", sys );

assuming that what 'sys' points to has enough room for
32 chars. While the result won't contain a trailing '\n'
it will have a '\0', so it's a proper string no matter
what popen() returns.

> pclose(stream);
> return bit;

And here you return the random value 'bit' is set to. What
is that supposed to be good for?

> }

> and$ cat nis.c
> /***********************************************
> This code returns the machine bit
> to the program bitinit
> ***********************************************/
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
> int operating_sys(char *nis ){
> FILE *stream;
> char *sysptr;
> int bit;
> sysptr = &nis[0];
> nis[6] = 0x0;

Setting the 7th element of the array to '\0' looks
even more weird than setting the first one in the
other function;-)

> stream=popen("/bin/nisdomainname","r");
> fread(sysptr,1,15,stream);
> pclose(stream);
> return bit;
> }

> As it is seen this two are doing almost same thing except the unix
> command in popen.

Yes, with the difference that what gets returned from
/bin/nisdomainname may have even less characters to give
the caller a chance to figure out what really was returned.

> is it possible to make it a single routine where the unix command
> nisdomainname or uname will be an argument?

Yes, of course, just pass it to popen() as the first argument
instead of the hard-coded string you pass it now (assuming
that the complete command with options is passed to the
function, otherwise you have to either use another string and
do some string-splicing to get the complete command or use
strcmp() to figure out what to call).

Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de


== 2 of 3 ==
Date: Sun, Apr 18 2010 9:25 pm
From: Uno


Jens Thoms Toerring wrote:
> rudra <bnrj.rudra@gmail.com> wrote:
>> I have 2 subroutine in c(which is ultimately called by fortran):
>> $ cat bit_unm.c
>> /***********************************************
>> This code returns the machine bit
>> to the program bitinit
>> ***********************************************/
>> #include <stdlib.h>
>> #include <stdio.h>
>> #include <string.h>
>
>> int operating_system(char *sys) {
>> FILE *stream;
>> char *sysptr;
>> int bit;
>
> This is an uninitialized variable that has some random value.
>
>> sysptr = &sys[0];
>> sys[0] = 0x0;
>
> Why do you go through all of this? Using the pointer you
> received would do quite well (and setting the first ele-
> ment of the array pointed is good for nothing).
>
>> stream = popen("/bin/uname -snm", "r");
>> fread(sysptr, 1, 32, stream);
>
> What you read from popen() won't contain a trailing '\0',
> so what the caller receives isn't a string (and the caller
> has no means of finding out how many characters got read
> if the stuff returned by popen() doesn't have a trailing
> '\n', e.g. in the case that what '/bin/uname' returnsed
> is longer than 32 characters (including the '\n' at the
> end). Also please note that popen() (and pclose()) isn't
> a standard C function (even though it is declared in
> <stdio.h> on POSIX compliant system).
>
> A slightly safer version would be
>
> fscanf( stream, "%31[^\n]", sys );
>
> assuming that what 'sys' points to has enough room for
> 32 chars. While the result won't contain a trailing '\n'
> it will have a '\0', so it's a proper string no matter
> what popen() returns.
>
>> pclose(stream);
>> return bit;
>
> And here you return the random value 'bit' is set to. What
> is that supposed to be good for?
>
>> }
>
>> and$ cat nis.c
>> /***********************************************
>> This code returns the machine bit
>> to the program bitinit
>> ***********************************************/
>> #include <stdlib.h>
>> #include <stdio.h>
>> #include <string.h>
>> int operating_sys(char *nis ){
>> FILE *stream;
>> char *sysptr;
>> int bit;
>> sysptr = &nis[0];
>> nis[6] = 0x0;
>
> Setting the 7th element of the array to '\0' looks
> even more weird than setting the first one in the
> other function;-)
>
>> stream=popen("/bin/nisdomainname","r");
>> fread(sysptr,1,15,stream);
>> pclose(stream);
>> return bit;
>> }
>
>> As it is seen this two are doing almost same thing except the unix
>> command in popen.
>
> Yes, with the difference that what gets returned from
> /bin/nisdomainname may have even less characters to give
> the caller a chance to figure out what really was returned.
>
>> is it possible to make it a single routine where the unix command
>> nisdomainname or uname will be an argument?
>
> Yes, of course, just pass it to popen() as the first argument
> instead of the hard-coded string you pass it now (assuming
> that the complete command with options is passed to the
> function, otherwise you have to either use another string and
> do some string-splicing to get the complete command or use
> strcmp() to figure out what to call).

I thought I'd try to follow along on this one. I don't know what OP
intends, but this was as close as I could come to divining it:

$ gcc -D_GNU_SOURCE -std=c99 -Wall -Wextra r1.c -o out
$ ./out
sys is Linux dan-desktop i686
$ cat r1.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main(void)
{
FILE *stream;
char *sys;
sys = malloc(100);
stream = popen("/bin/uname -snm", "r");
fscanf( stream, "%31[^\n]", sys );
printf("sys is %s\n", sys);
pclose(stream);
return 0;
}

// gcc -D_GNU_SOURCE -std=c99 -Wall -Wextra r1.c -o out
$

Question: With this input as an example, what is happening in that
fscanf line?
--
Uno


== 3 of 3 ==
Date: Sun, Apr 18 2010 10:39 pm
From: Nick Keighley


On 18 Apr, 18:29, rudra <bnrj.ru...@gmail.com> wrote:
> I have 2 subroutine in c(which is ultimately called by fortran):
> $ cat bit_unm.c
> /***********************************************
>  This code returns the machine bit
>  to the program bitinit
>  ***********************************************/
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
>
> int operating_system(char *sys) {
>     FILE *stream;
>     char *sysptr;
>     int bit;
>     sysptr = &sys[0];
>     sys[0] = 0x0;
>     stream = popen("/bin/uname -snm", "r");
>     fread(sysptr, 1, 32, stream);
>     pclose(stream);
>     return bit;
>
> }

bearing Jens's remarks in mind... Is this any help

int operating_system(char *sys, const char *cmd)
{
FILE *stream;
char *sysptr;
int bit;
sysptr = &sys[0];
sys[0] = 0x0;
stream = popen (cmd, "r");
fread (sysptr, 1, 32, stream);
pclose (stream);
return bit;
}

==============================================================================
TOPIC: mostly OT (was Re: In the Matter of Herb Schildt: a Detailed Analysis
of "C: The Complete Nonsense")
http://groups.google.com/group/comp.lang.c/t/caf17fab4e7d8530?hl=en
==============================================================================

== 1 of 5 ==
Date: Sun, Apr 18 2010 11:14 am
From: Richard


Tim Streater <timstreater@waitrose.com> writes:

> In article <hqfdgt$e7d$3@news.xmission.com>,
> gazelle@shell.xmission.com (Kenny McCormack) wrote:
>
>> In article <50282471-3258-4570-a035-3c2e6066d5fd@s9g2000yqa.googlegroups.com>,
>> spinoza1111 <spinoza1111@yahoo.com> wrote:
>> >On Apr 16, 3:55 am, Seebs <usenet-nos...@seebs.net> wrote:
>> >> On 2010-04-15, Keith Thompson <ks...@mib.org> wrote:
>> >>
>> >> > Ok, so Nilges wrote about something that Seebs's mother is
>> >> > alleged to have posted on her blog.  Fine, we've come to expect that
>> >> > kind of crap from him.
>> >>
>> >> Actually, I have to dispute this.  I was absolutely shocked that
>> >> he actually managed to successfully identify my mom.  (To save him
>> >> trouble, the UFO nut "Linda Seebach" is a different person.)
>> >
>> >I don't know what you are talking about. You link to your mother's
>> >blog in your blog.
>>
>> It is clear by now that Seebs is, like most Republicans nowadays, just
>> spewing. Putting out words that sound good (i.e., advance their agenda),
>> with zero concern for whether they are true, valid, or in any way map to
>> (easily verifiable) reality.
>
> Ah, the brown-noser's back.

Referring to oneself in the 3rd person is the first sign of being in
need of some self importance reduction surgery.


--
"Avoid hyperbole at all costs, its the most destructive argument on
the planet" - Mark McIntyre in comp.lang.c


== 2 of 5 ==
Date: Sun, Apr 18 2010 1:46 pm
From: Keith Thompson


Tim Streater <timstreater@waitrose.com> writes:
> In article <hqfdgt$e7d$3@news.xmission.com>,
> gazelle@shell.xmission.com (Kenny McCormack) wrote:
[snip]
>
> Ah, the brown-noser's back.

Tim, I'm sure that everyone who cares is already aware that Kenny is
back.

Please don't feed the troll.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"


== 3 of 5 ==
Date: Sun, Apr 18 2010 1:52 pm
From: Keith Thompson


Tim Streater <timstreater@waitrose.com> writes:
> In article
> <b4dbc741-0daf-49bc-bf45-f830c8cd5f68@i37g2000yqn.googlegroups.com>,
> spinoza1111 <spinoza1111@yahoo.com> wrote:
[more of the same]
>
> Are you deliberately stupid? Or are you simply out of arguments today
> (like yesterday, and the day before, and the day before *that*, ad
> fucking nauseam).
[snip]
> You've been ground into the dust in the last few months, dimwit, why not
> admit it.

He never will. He's been doing this for years, and his behavior has
been quite consistent. It's borderline insane to think he's going to
change because you poke at him *just one more time*.

When are you going to admit that, Tim, and give up?

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"


== 4 of 5 ==
Date: Sun, Apr 18 2010 2:33 pm
From: gazelle@shell.xmission.com (Kenny McCormack)


In article <lnk4s4mqut.fsf@nuthaus.mib.org>,
Keith Thompson <kst-u@mib.org> wrote:
>Tim Streater <timstreater@waitrose.com> writes:
>> In article <hqfdgt$e7d$3@news.xmission.com>,
>> gazelle@shell.xmission.com (Kenny McCormack) wrote:
>[snip]
>>
>> Ah, the brown-noser's back.
>
>Tim, I'm sure that everyone who cares is already aware that Kenny is
>back.

I never left.

--
(This discussion group is about C, ...)

Wrong. It is only OCCASIONALLY a discussion group
about C; mostly, like most "discussion" groups, it is
off-topic Rorsharch revelations of the childhood
traumas of the participants...

== 5 of 5 ==
Date: Sun, Apr 18 2010 11:41 pm
From: spinoza1111


On Apr 19, 1:26 am, Tim Streater <timstrea...@waitrose.com> wrote:
> In article
> <b4dbc741-0daf-49bc-bf45-f830c8cd5...@i37g2000yqn.googlegroups.com>,
>
>
>
>
>
>  spinoza1111<spinoza1...@yahoo.com> wrote:
> > On Apr 13, 12:51 am, Tim Streater <timstrea...@waitrose.com> wrote:
> > > In article
> > > <c474d1c9-77dd-4d0d-a1c0-74996f541...@x12g2000yqx.googlegroups.com>,
>
> > >  spinoza1111<spinoza1...@yahoo.com> wrote:
>
> > > [snip]
>
> > > > The fact is that C is not portable. Because it is possible to make
> > > > things subtly dependent on hardware, any port needs a great deal of
> > > > diligence. The fact that this diligence isn't manifest doesn't change
> > > > this.
>
> > > > If you want to write portable code, it is folly to int main(). Use
> > > > Java or C Sharp.
>
> > > Just because you don't know how to write portable code in C, bozo, does
> > > not mean that others can't. At SLAC in the mid-late 80s, we had a
> > > threads kernel written in C (that supported events, semaphores, timers
> > > [1], and thread priorities) that it was no great effort to port to DEC's
> > > VAX/VMS and to IBM's VM/CMS. That's substantially different OSes,
> > > different endiannesses [2], and different character sets. It's called
> > > being professional, Spinny. You should try it sometime instead of just
> > > being a mouth.
>
> > > [1] Some of this work exposed bugs in IBM's timer services that (having
> > > access to the assembler source code) we fixed.
>
> > > [2] which affected how structs were packed, as I recall, so that
> > > required some care.
>
> > [1] and [2] show, in fact, that C code is NOT PORTABLE. You're
> > bragging about doing your job, but portability means "run anywhere
> > without change or the need for research to disprove portability".
>
> Are you deliberately stupid? Or are you simply out of arguments today
> (like yesterday, and the day before, and the day before *that*, ad
> fucking nauseam).
>
> [1] exposed errors in *IBM's* code - which plain didn't work. Once our
> IBM systems programmers had *fixed these bugs*, the C code in question
> ran fine with no changes required to it.

Portability in fact reduces dependencies even on bugs. Basically, if
the virtual machine is effectively bug-free, bugs lower down do not
effect truly portable code. But C runtime is not a virtual machine and
thus C programs can be affected by bugs in the support software at any
level.

>
> [2] related to the endianess of the two machines, which is obviously
> different.

This also shows that the code wasn't portable, I'm afraid. You need to
learn Java and C Sharp.

>
> Once we'd modified the C slightly to account for this, the *same* source
> was used on *both* architectures - without even any pre-processor work
> required.

If it was modified it wasn't the same.

>
> You've been ground into the dust in the last few months, dimwit, why not
> admit it.

Your savage imagery doesn't frighten me, because I'd whip your ass in
any real fight.
>
> --
> Tim
>
> "That excessive bail ought not to be required, nor excessive fines imposed,
> nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689


==============================================================================
TOPIC: pointer
http://groups.google.com/group/comp.lang.c/t/a4a35284e41ec5c1?hl=en
==============================================================================

== 1 of 3 ==
Date: Sun, Apr 18 2010 11:25 am
From: Richard


Seebs <usenet-nospam@seebs.net> writes:

> On 2010-04-18 11:19:32 -0500, Richard said:
>
>> raltbos@xs4all.nl (Richard Bos) writes:
>>
>>> rs2010 <rais.iut@gmail.com> wrote:
>>>
>>>> My name is rais,095446. I have a question:
>>>
>>> So do I.
>>>
>>> Would you please post the email address of your teacher at IUT here? The
>>> one who led you to ask this question in this newsgroup, I mean. We have
>>> a message for him.
>>>
>>> Richard
>>
>> +1 idiot point there Rich. We are all super impressed. The fact that
>> this is a C programming group and people coming here look for help
>> didn't cross your mind at all did it? How do you think people do their
>> homework? Guess?
>
> I usually started by looking at the book, or attending class.

That's nice. But what makes you think anyone is at all interested in
that. You know NOTHING about the poster.

>
> But thanks for posting something mind-numbingly stupid, demonstrating
> that you don't have enough capacity for abstract thought to recognize
> the pattern when several people a day post identically formatted
> questions for a week or two.

Way for the entire point to go flying past your self important
head. If it is so obvious then IGNORE it. If you have something to offer
the poster then do so. Else STFU.

>
> This is useful to me, because I'm trying out a new newsreader and I
> hadn't thought to import my old killfile.
>
> -s

Let me get this straight : you think this is NOT a good place to ask
questions about the C programming language? I realise you're a self
inflated dick head, but really, I am surprised that even you think this
is not a good place to ask questions about C. Is it only for you to
curry favour with Heathfield and the top table?

You and your ilk have ruined this NG.

--
"Avoid hyperbole at all costs, its the most destructive argument on
the planet" - Mark McIntyre in comp.lang.c


== 2 of 3 ==
Date: Sun, Apr 18 2010 3:28 pm
From: Tim Streater


In article <oevr97-2ia.ln1@news.eternal-september.org>,
Richard <rgrdev_@gmail.com> wrote:

> Let me get this straight : you think this is NOT a good place to ask
> questions about the C programming language? I realise you're a self
> inflated dick head, but really, I am surprised that even you think this
> is not a good place to ask questions about C. Is it only for you to
> curry favour with Heathfield and the top table?

Brown-noser #2 is back. There's only Twinkle-toes missing now.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689


== 3 of 3 ==
Date: Sun, Apr 18 2010 10:42 pm
From: Nick <3-nospam@temporary-address.org.uk>


Tim Streater <timstreater@waitrose.com> writes:

> In article <oevr97-2ia.ln1@news.eternal-september.org>,
> Richard <rgrdev_@gmail.com> wrote:
>
>> Let me get this straight : you think this is NOT a good place to ask
>> questions about the C programming language? I realise you're a self
>> inflated dick head, but really, I am surprised that even you think this
>> is not a good place to ask questions about C. Is it only for you to
>> curry favour with Heathfield and the top table?
>
> Brown-noser #2 is back. There's only Twinkle-toes missing now.

Yes, and the only reason I've read a word from any of the three is
because you've quoted them. Why?
--
Online waterways route planner | http://canalplan.eu
Plan trips, see photos, check facilities | http://canalplan.org.uk

==============================================================================
TOPIC: New version 1.8 of UML state machine code generator
http://groups.google.com/group/comp.lang.c/t/b88c05c9a32070c5?hl=en
==============================================================================

== 1 of 2 ==
Date: Sun, Apr 18 2010 1:48 pm
From: Keith Thompson


Peter Mueller <peter.o.mueller@gmx.de> writes:
> Hello list readers,
> a new version of the sinelabore codegenerator is available for
> download.
>
> SinelaboreRT generates C/C++ - Code from UML state charts.
[snip]

What is "C/C++" code?

Do you mean that the code it generates code that can be compiled
either as C or as C++, or that the tool has an option that tells it
which language to generate? Or, like many people who use the term
"C/C++", are you unclear that they're two distinct languages?

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"


== 2 of 2 ==
Date: Sun, Apr 18 2010 2:26 pm
From: gazelle@shell.xmission.com (Kenny McCormack)


In article <lnfx2smqqp.fsf@nuthaus.mib.org>,
Keith Thompson <kst-u@mib.org> wrote:
>Peter Mueller <peter.o.mueller@gmx.de> writes:
>> Hello list readers,
>> a new version of the sinelabore codegenerator is available for
>> download.
>>
>> SinelaboreRT generates C/C++ - Code from UML state charts.
>[snip]
>
>What is "C/C++" code?

You are such a moron. Everybody knows what normal people mean when they
say C/C++. To the OP: Ignore Kike the Troll.

--
(This discussion group is about C, ...)

Wrong. It is only OCCASIONALLY a discussion group
about C; mostly, like most "discussion" groups, it is
off-topic Rorsharch revelations of the childhood
traumas of the participants...


==============================================================================
TOPIC: memset pointer to 0
http://groups.google.com/group/comp.lang.c/t/0844332d363fdb33?hl=en
==============================================================================

== 1 of 2 ==
Date: Sun, Apr 18 2010 5:04 pm
From: Richard Heathfield


Seebs wrote:
> On 2010-04-15, ImpalerCore <jadill33@gmail.com> wrote:
>> Followup question. If I have two pointers 'a' and 'b', and 'b' is set
>> explicitly to NULL, can I memcpy 'b' to 'a' and be guaranteed that 'a'
>> will be interpreted as NULL?
>
> Assuming they're the same type of pointer, I am pretty sure you are,
> because you're assured that copying the bytes out of an object and
> then back into it preserves it.

Either you have misread his question, or I have.

It seems to me that he is asking whether the following program is
required to print "Seebs is right":

#include <stdio.h>
#include <string.h>

#define ADJUST_TO_TASTE 1

int main(void)
{
void *a;
void *b = NULL;
size_t itisnotclearwhatvaluethisshouldbe = ADJUST_TO_TASTE;
memcpy(a, b, itisnotclearwhatvaluethisshouldbe);
printf("Seebs is %s\n", (a == NULL) ? "right" : "wrong");
return 0;
}

If the question is really about memcpy(&a, &b, sizeof a) then of course
you are correct.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within


== 2 of 2 ==
Date: Sun, Apr 18 2010 11:45 pm
From: Jon Du Kim


ImpalerCore wrote:
> Quick question. Is there a guarantee that memset a pointer to 0 will
> be equivalent to assigning the NULL pointer? I think not, since there
> can be systems where the null pointer is non-zero. Is this the only
> reason why?

Please note that for maximum backwards compatibility to
older systems you should use bzero().
You should always ensure your code can run on
even old implementations.
Be careful this is the sort of thing
you can dinged on here.

==============================================================================
TOPIC: How often do you have to work around implementations?
http://groups.google.com/group/comp.lang.c/t/fa1b08d59fe3d0d0?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Apr 18 2010 5:10 pm
From: Richard Heathfield


Seebs wrote:
> Obviously, in general, you ought to write clean, portable, code.
>
> Something that's bitten me a few times recently is cases in which
> implementations were buggy -- rarely, to be fair, in the core C language,
> but "standard" system extensions like POSIX conformance.
>
> Does this happen to other people? (The recent example of MSVC++ having a
> buggy preprocessor is presumably one example.)

A couple of Borland examples spring to mind. Firstly, I had no end of
trouble getting Borland to compile anything that uses errno (see below).
Secondly, the math library is a bit screwed.

> What do you do about it?

I deal with the first problem by simply not using errno if there is even
the slightest possibility that the code will be compiled under Borland
at some point (and, for most of the code I write, that's a distinct
possibility, as a result of which I have basically stuffed errno onto
the same shelf as goto and gets.

The second problem is rather more interesting, in that it can be fixed
easily as follows:

double pointless_double = 1.0;

or, if I feel so inclined:

double Borland_really_should_fix_this_stupid_bug = 3.14159;

<snip>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within

==============================================================================
TOPIC: seebs/schildt
http://groups.google.com/group/comp.lang.c/t/0c84debf9a4f144b?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Apr 18 2010 5:22 pm
From: Richard Heathfield


spinoza1111 wrote:
> On Apr 17, 11:31 pm, Seebs <usenet-nos...@seebs.net> wrote:

<nonsense snipped>

>> Correcting him on points of fact has no discernable effect. He just
>> sticks with them.
>
> I think you confuse "facts" with "opinions of my friends". We've in
> fact learned that one of your major "facts" (a C program must have a
> main() with an int,

That's not what he said. He said that the C Standard mandates
implementation support with defined semantics for a program with a
return type of int for the main() function, for hosted implementations.
That is true. Your inability to understand a truth does not invalidate
that truth.

<snip>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within

==============================================================================
TOPIC: adding two hex numbers
http://groups.google.com/group/comp.lang.c/t/29688d45a35bc095?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Apr 18 2010 5:26 pm
From: "Dennis \(Icarus\)"

"Keith Thompson" <kst-u@mib.org> wrote in message
news:lny6gmnbiv.fsf@nuthaus.mib.org...
> Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:
>> Keith Thompson <kst-u@mib.org> writes:
>> > Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:
>> >> Keith Thompson <kst-u@mib.org> writes:
>> > [...]
>> >> > For historical reasons, many compilers will (after printing a
>> >> > warning)
>> >> > generate an implicit conversion, making the above equivalent to the
>> >> > legal declaration
>> >> >
>> >> > unsigned int *x = (unsigned int)0x37a00000;
>> >>
>> >> ITYM: unsigned int *x = (unsigned int*)0x37a00000;
>> >
>> > Yes, you're right.
>> >
>> > Sheesh, we're nitpicking about punctuation now? 8-)} 8-)}
>>
>> Nope, I thought we were trying to help newbs. Sorry if it was
>> taken the wrong way.
>
> Um, did you miss the smileys?
>
> It was a significant correction, and I thank you for making it.

I didn't. FWIW, I thought it especially amusing given that had commented on
original poster's missing semi-colon after the declaration of x :-)

Dennis


==============================================================================
TOPIC: cast
http://groups.google.com/group/comp.lang.c/t/041a2b73cefbd536?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Apr 18 2010 11:40 pm
From: "io_x"

"io_x" <a@b.c.invalid> ha scritto nel messaggio
news:4bca94e8$0$827$4fafbaef@reader5.news.tin.it...
> i find more clear this way above of write the function,
> only i prefer
>
> int square_root(double *result_ptr, double x)
> using like
>
> double r;
>
> if(square_root(&r, 110.11)!=0)
> {error code
> }
> all ok
> so
> error_code_int funzione(result_pointers, args);
>
> where error_code_int==0 if the function is ok and not error
> and this for the biggest possible set of function
> (almost always in this way because i not remember well all the
> functions conventions and every time i have to see books)

this is only the theory the pratic is many time
error_code_int funzione(result_pointers, args);

with error_code_int==1 all ok
error_code_int==0 error

==============================================================================
TOPIC: An exercise, regarding the implementation of an "if"
http://groups.google.com/group/comp.lang.c/t/e21de5b677e11cbd?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Apr 18 2010 11:33 pm
From: Michael Foukarakis


On Apr 18, 8:22 am, "io_x" <a...@b.c.invalid> wrote:
> "Eric Sosman"  ha scritto nel messaggionews:hqahm8$10e$1@news.eternal-september.org...
>
>
>
> > On 4/15/2010 5:21 PM, Stefan Ram wrote:
> >> (Stefan Ram) writes:
> >>> 1 for logarithm), but do not use any control statement (such
> >>> as »if« or »while«) nor any operator with conditional
> >>> evaluation (such as ?:,&&, ||).
>
> >>    The implementation using an array was also what I had in
> >>    mind (even though I was mistakenly under the impression
> >>    that I had to define two helper functions, due to a previous
> >>    version of this exercise where this was necessary.)
>
> >>    Of course, it would be very interesting if anyone could
> >>    find a solution without using an array (I don't think that
> >>    this can be done).
>
> >     Here's a filthy, filthy dirty approach (I hope I've matched
> > the parentheses correctly(:
>
> > double f(int c, double x) {
> >     return (double(*)(double)(void*)(((uintptr_t)
> >         (void*)sin)^((((uintptr_t)(void*)sin)^
> >         ((uintptr_t)(void*)log))*c)))(x);
> > }
>
> > Unfortunately, it relies on the existence of uintptr_t (not
> > guaranteed) and on the non-portable operations of converting
> > function pointers to void* and back.
>
> i not understand well;
> i find the exercise not useful, the answer too much complex;
> the problem is not how to make begin the things easy, difficult;
> but how difficult exercise can be easy or at last with a chance
> of to be understood

The exercise is quite useful in various applications; although some of
the answers are unnecessarily complex and error-prone (such as the one
you quoted).

==============================================================================
TOPIC: C - gets() function implementation help
http://groups.google.com/group/comp.lang.c/t/7bd0bc765a2e9603?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Apr 18 2010 11:43 pm
From: "io_x"


"Richard" ha scritto nel messaggio

why do you have to insult people?

==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.c"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.c?hl=en

To unsubscribe from this group, send email to comp.lang.c+unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate