Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #8703 > unrolled thread

is there anything unstandard in the c part here

Started byUno <Uno@example.invalid>
First post2011-07-25 17:45 -0600
Last post2011-08-01 15:42 +0100
Articles 20 on this page of 125 — 33 participants

Back to article view | Back to comp.lang.c


Contents

  is there anything unstandard in the c part here Uno <Uno@example.invalid> - 2011-07-25 17:45 -0600
    Re: is there anything unstandard in the c part here John Gordon <gordon@panix.com> - 2011-07-25 23:53 +0000
      Re: is there anything unstandard in the c part here gwowen <gwowen@gmail.com> - 2011-07-26 01:50 -0700
        Re: is there anything unstandard in the c part here tom st denis <tom@iahu.ca> - 2011-07-26 06:17 -0700
          Re: is there anything unstandard in the c part here Kenneth Brody <kenbrody@spamcop.net> - 2011-07-26 11:08 -0400
            Re: is there anything unstandard in the c part here tom st denis <tom@iahu.ca> - 2011-07-26 10:51 -0700
              Re: is there anything unstandard in the c part here Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-27 00:08 -0700
                Re: is there anything unstandard in the c part here Kenneth Brody <kenbrody@spamcop.net> - 2011-07-27 13:41 -0400
                  Re: is there anything unstandard in the c part here Angel <angel+news@spamcop.net> - 2011-07-28 10:58 +0000
                    Re: is there anything unstandard in the c part here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-07-28 13:58 +0100
              Re: is there anything unstandard in the c part here Kenneth Brody <kenbrody@spamcop.net> - 2011-07-27 13:24 -0400
                Re: is there anything unstandard in the c part here Angel <angel+news@spamcop.net> - 2011-07-28 11:07 +0000
                  Re: is there anything unstandard in the c part here Kenneth Brody <kenbrody@spamcop.net> - 2011-07-28 13:02 -0400
                  Re: is there anything unstandard in the c part here Roberto Waltman <usenet@rwaltman.com> - 2011-07-28 17:16 -0400
        Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-07-26 09:39 -0400
          Re: is there anything unstandard in the c part here Gareth Owen <gwowen@gmail.com> - 2011-07-27 07:24 +0100
            Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-07-27 07:11 -0400
            Re: is there anything unstandard in the c part here Noob <root@127.0.0.1> - 2011-07-27 15:20 +0200
            Re: is there anything unstandard in the c part here John Gordon <gordon@panix.com> - 2011-07-27 14:25 +0000
              Re: is there anything unstandard in the c part here Keith Thompson <kst-u@mib.org> - 2011-07-27 08:10 -0700
                Re: is there anything unstandard in the c part here John Gordon <gordon@panix.com> - 2011-07-27 17:42 +0000
                  Re: is there anything unstandard in the c part here Keith Thompson <kst-u@mib.org> - 2011-07-27 12:02 -0700
                    Re: is there anything unstandard in the c part here Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-28 16:04 -0700
                  Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-07-27 22:35 -0400
            Re: is there anything unstandard in the c part here Kenneth Brody <kenbrody@spamcop.net> - 2011-07-27 13:34 -0400
              Re: is there anything unstandard in the c part here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-07-28 02:13 +0100
                Re: is there anything unstandard in the c part here Ike Naar <ike@sverige.freeshell.org> - 2011-07-28 07:33 +0000
                  Re: is there anything unstandard in the c part here Willem <willem@toad.stack.nl> - 2011-07-28 07:58 +0000
                    Re: is there anything unstandard in the c part here pete <pfiland@mindspring.com> - 2011-07-28 04:25 -0400
                  Re: is there anything unstandard in the c part here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-07-28 12:26 +0100
              Re: is there anything unstandard in the c part here gwowen <gwowen@gmail.com> - 2011-07-28 04:24 -0700
                Re: is there anything unstandard in the c part here Angel <angel+news@spamcop.net> - 2011-07-28 11:36 +0000
                  Re: is there anything unstandard in the c part here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-07-28 15:11 +0100
                    Re: is there anything unstandard in the c part here Angel <angel+news@spamcop.net> - 2011-07-28 14:50 +0000
                      Re: is there anything unstandard in the c part here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-07-28 17:28 +0100
                      Re: is there anything unstandard in the c part here Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-07-28 10:38 -0600
                        Re: is there anything unstandard in the c part here Michael Press <rubrum@pacbell.net> - 2011-08-02 17:20 -0700
                          Re: is there anything unstandard in the c part here Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-08-02 23:26 -0600
                            Re: is there anything unstandard in the c part here Michael Press <rubrum@pacbell.net> - 2011-08-03 16:09 -0700
                    Re: is there anything unstandard in the c part here Kenneth Brody <kenbrody@spamcop.net> - 2011-07-28 13:22 -0400
                    Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-07-28 22:22 -0400
                      Re: is there anything unstandard in the c part here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-07-29 04:17 +0100
                        Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-07-28 23:40 -0400
                          Re: is there anything unstandard in the c part here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-07-29 13:52 +0100
                  Re: is there anything unstandard in the c part here Gareth Owen <gwowen@gmail.com> - 2011-07-31 09:19 +0100
                    Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-07-31 09:49 -0400
                      Re: is there anything unstandard in the c part here Gareth Owen <gwowen@gmail.com> - 2011-08-02 06:56 +0100
                        Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-08-02 06:53 -0400
                Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-07-28 07:36 -0400
                Re: is there anything unstandard in the c part here Kenneth Brody <kenbrody@spamcop.net> - 2011-07-28 13:16 -0400
        Re: is there anything unstandard in the c part here John Gordon <gordon@panix.com> - 2011-07-26 14:58 +0000
          Re: is there anything unstandard in the c part here Paul N <gw7rib@aol.com> - 2011-07-26 14:56 -0700
            Re: is there anything unstandard in the c part here Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-27 00:13 -0700
            Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-07-27 07:28 -0400
              Re: is there anything unstandard in the c part here Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-27 04:44 -0700
              Re: is there anything unstandard in the c part here Keith Thompson <kst-u@mib.org> - 2011-07-27 08:24 -0700
                Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-07-27 22:41 -0400
                  Re: is there anything unstandard in the c part here Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-28 16:19 -0700
                Re: is there anything unstandard in the c part here Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-28 16:06 -0700
                Re: is there anything unstandard in the c part here Uno <Uno@example.invalid> - 2011-07-30 01:54 -0600
        Re: is there anything unstandard in the c part here Kenneth Brody <kenbrody@spamcop.net> - 2011-07-26 11:01 -0400
          Re: is there anything unstandard in the c part here Chad <cdalten@gmail.com> - 2011-07-26 09:49 -0700
            Re: is there anything unstandard in the c part here Kenneth Brody <kenbrody@spamcop.net> - 2011-07-26 13:18 -0400
            Re: is there anything unstandard in the c part here John Gordon <gordon@panix.com> - 2011-07-26 17:44 +0000
            Re: is there anything unstandard in the c part here Angel <angel+news@spamcop.net> - 2011-07-26 17:45 +0000
            Re: is there anything unstandard in the c part here Seebs <usenet-nospam@seebs.net> - 2011-07-26 18:42 +0000
              Re: is there anything unstandard in the c part here Bill Waddington <william.waddington@beezmo.com> - 2011-07-26 11:55 -0700
                Re: is there anything unstandard in the c part here lawrence.jones@siemens.com - 2011-07-26 18:11 -0400
                  Re: is there anything unstandard in the c part here Uno <Uno@example.invalid> - 2011-07-27 20:58 -0600
              Re: is there anything unstandard in the c part here arnuld <sunrise@invalid.address> - 2011-08-02 05:24 +0000
                Re: is there anything unstandard in the c part here Ian Collins <ian-news@hotmail.com> - 2011-08-02 18:10 +1200
                Re: is there anything unstandard in the c part here Keith Thompson <kst-u@mib.org> - 2011-08-02 00:03 -0700
                Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-08-02 06:59 -0400
                Re: is there anything unstandard in the c part here Seebs <usenet-nospam@seebs.net> - 2011-08-02 16:06 +0000
        Re: is there anything unstandard in the c part here Seebs <usenet-nospam@seebs.net> - 2011-07-26 18:42 +0000
        Re: is there anything unstandard in the c part here Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-27 00:06 -0700
          Re: is there anything unstandard in the c part here Gareth Owen <gwowen@gmail.com> - 2011-08-02 06:58 +0100
            Re: is there anything unstandard in the c part here Keith Thompson <kst-u@mib.org> - 2011-08-02 00:01 -0700
              Re: is there anything unstandard in the c part here Gareth Owen <gwowen@gmail.com> - 2011-08-05 06:22 +0100
                Re: is there anything unstandard in the c part here Keith Thompson <kst-u@mib.org> - 2011-08-04 23:54 -0700
                Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-08-05 07:37 -0400
                  Re: is there anything unstandard in the c part here Gareth Owen <gwowen@gmail.com> - 2011-08-13 08:05 +0100
                    Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-08-13 08:26 -0400
                    Re: is there anything unstandard in the c part here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-08-13 14:09 +0100
            Re: is there anything unstandard in the c part here Kenneth Brody <kenbrody@spamcop.net> - 2011-08-02 12:58 -0400
              Re: is there anything unstandard in the c part here Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-08-10 01:31 -0700
                Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-08-10 08:28 -0400
                  Re: is there anything unstandard in the c part here Gareth Owen <gwowen@gmail.com> - 2011-08-13 08:14 +0100
                    Re: is there anything unstandard in the c part here "io_x" <a@b.c.invalid> - 2011-08-13 10:08 +0200
                    Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-08-13 08:35 -0400
                    Re: is there anything unstandard in the c part here "J. J. Farrell" <jjf@bcs.org.uk> - 2011-08-14 04:00 +0100
                    Re: is there anything unstandard in the c part here Kenneth Brody <kenbrody@spamcop.net> - 2011-08-15 14:43 -0400
            Re: is there anything unstandard in the c part here Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-08-10 01:34 -0700
              Re: is there anything unstandard in the c part here Gareth Owen <gwowen@gmail.com> - 2011-08-13 08:16 +0100
    Re: is there anything unstandard in the c part here Barry Schwarz <schwarzb@dqel.com> - 2011-07-25 17:52 -0700
      Re: is there anything unstandard in the c part here "J. J. Farrell" <jjf@bcs.org.uk> - 2011-07-26 02:10 +0100
      Re: is there anything unstandard in the c part here Seebs <usenet-nospam@seebs.net> - 2011-07-26 06:17 +0000
        Re: is there anything unstandard in the c part here Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-26 00:03 -0700
          Re: is there anything unstandard in the c part here "Kleuskes & Moos" <kleuske@xs4all.nl> - 2011-07-26 00:08 -0700
          Re: is there anything unstandard in the c part here Ian Collins <ian-news@hotmail.com> - 2011-07-26 19:43 +1200
          Re: is there anything unstandard in the c part here Seebs <usenet-nospam@seebs.net> - 2011-07-26 07:56 +0000
            Re: is there anything unstandard in the c part here Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-26 04:50 -0700
              Re: is there anything unstandard in the c part here Angel <angel+news@spamcop.net> - 2011-07-26 12:03 +0000
              Re: is there anything unstandard in the c part here Seebs <usenet-nospam@seebs.net> - 2011-07-26 18:42 +0000
              Re: is there anything unstandard in the c part here Nobody <nobody@nowhere.com> - 2011-07-27 19:10 +0100
          Re: is there anything unstandard in the c part here Angel <angel+news@spamcop.net> - 2011-07-26 11:53 +0000
    Re: is there anything unstandard in the c part here Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-26 00:07 -0700
      Re: is there anything unstandard in the c part here James Kuyper <jameskuyper@verizon.net> - 2011-07-26 06:29 -0400
        Re: is there anything unstandard in the c part here Uno <Uno@example.invalid> - 2011-07-27 21:32 -0600
          Re: is there anything unstandard in the c part here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-07-28 12:19 +0100
            Re: is there anything unstandard in the c part here pete <pfiland@mindspring.com> - 2011-07-28 20:25 -0400
              Re: is there anything unstandard in the c part here Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-07-28 18:38 -0600
                Re: is there anything unstandard in the c part here pete <pfiland@mindspring.com> - 2011-07-28 21:05 -0400
            Re: is there anything unstandard in the c part here "Morris Keesan" <mkeesan@post.harvard.edu> - 2011-07-29 14:16 -0400
              Re: is there anything unstandard in the c part here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-07-29 20:27 +0100
              Re: is there anything unstandard in the c part here Uno <Uno@example.invalid> - 2011-07-30 01:10 -0600
            Re: is there anything unstandard in the c part here Uno <Uno@example.invalid> - 2011-07-30 00:56 -0600
              Re: is there anything unstandard in the c part here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-07-30 12:23 +0100
                Re: is there anything unstandard in the c part here Uno <Uno@example.invalid> - 2011-08-01 00:01 -0600
                  Re: is there anything unstandard in the c part here Ike Naar <ike@sverige.freeshell.org> - 2011-08-01 07:50 +0000
                    Re: is there anything unstandard in the c part here Uno <Uno@example.invalid> - 2011-08-01 07:43 -0600
                      Re: is there anything unstandard in the c part here Ike Naar <ike@sdf.lonestar.org> - 2011-08-01 15:20 +0000
                  Re: is there anything unstandard in the c part here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-08-01 14:27 +0100
                    Re: is there anything unstandard in the c part here Uno <Uno@example.invalid> - 2011-08-01 08:02 -0600
                      Re: is there anything unstandard in the c part here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-08-01 15:42 +0100

Page 4 of 7 — ← Prev page 1 2 3 [4] 5 6 7  Next page →


#8739

FromKenneth Brody <kenbrody@spamcop.net>
Date2011-07-26 11:01 -0400
Message-ID<fNudnQccMvojS7PTnZ2dnUVZ_rKdnZ2d@bestweb.net>
In reply to#8722
On 7/26/2011 4:50 AM, gwowen wrote:
> On Jul 26, 12:53 am, John Gordon<gor...@panix.com>  wrote:
>>    char *testc(void)
>>
>>>       char * pa;
>>>       pa = (char *)malloc (50);
>>
>> Don't cast the return value of malloc.  There's no need, and it can hide
>> errors later on if you change the type of pa but forget to change the
>> cast.
>
> Please don't give (distinctly debatable) style tips as if they were
> hard and fast rules.  Not casting malloc has both benefits and
> drawbacks w.r.t. hiding bugs, and to suggest otherwise is to
> demonstrate incomplete understanding.

Please explain when, in C, there is a "benefit" to casting the return from 
malloc().

Unless you are using an ancient C compiler which predates "void *", there is 
no good reason I can think of for casting the return from malloc().  And, 
even on those ancient systems, the return was defined as "char *", making 
the cast in the instant case redundant.

-- 
Kenneth Brody

[toc] | [prev] | [next] | [standalone]


#8748

FromChad <cdalten@gmail.com>
Date2011-07-26 09:49 -0700
Message-ID<1c6b604c-cb47-4c76-b4ca-e26407e5d6a7@x19g2000prc.googlegroups.com>
In reply to#8739
On Jul 26, 8:01 am, Kenneth Brody <kenbr...@spamcop.net> wrote:
> On 7/26/2011 4:50 AM, gwowen wrote:
>
> > On Jul 26, 12:53 am, John Gordon<gor...@panix.com>  wrote:
> >>    char *testc(void)
>
> >>>       char * pa;
> >>>       pa = (char *)malloc (50);
>
> >> Don't cast the return value of malloc.  There's no need, and it can hide
> >> errors later on if you change the type of pa but forget to change the
> >> cast.
>
> > Please don't give (distinctly debatable) style tips as if they were
> > hard and fast rules.  Not casting malloc has both benefits and
> > drawbacks w.r.t. hiding bugs, and to suggest otherwise is to
> > demonstrate incomplete understanding.
>
> Please explain when, in C, there is a "benefit" to casting the return from
> malloc().
>
> Unless you are using an ancient C compiler which predates "void *", there is
> no good reason I can think of for casting the return from malloc().  And,
> even on those ancient systems, the return was defined as "char *", making
> the cast in the instant case redundant.
>

Let's say I'm working on a programming project that uses multiple
languages. And now let's say that the only (apparent) way I can get C
to cooperate with the other programming languages is to cast the
return value from malloc(). How would you get around avoiding casting
the return from malloc()?

Chad

[toc] | [prev] | [next] | [standalone]


#8749

FromKenneth Brody <kenbrody@spamcop.net>
Date2011-07-26 13:18 -0400
Message-ID<k8idnSl3xpNJa7PTnZ2dnUVZ_uqdnZ2d@bestweb.net>
In reply to#8748
On 7/26/2011 12:49 PM, Chad wrote:
> On Jul 26, 8:01 am, Kenneth Brody<kenbr...@spamcop.net>  wrote:
>> On 7/26/2011 4:50 AM, gwowen wrote:
>>
>>> On Jul 26, 12:53 am, John Gordon<gor...@panix.com>    wrote:
[...]
>>>> Don't cast the return value of malloc.  There's no need, and it can hide
>>>> errors later on if you change the type of pa but forget to change the
>>>> cast.
>>
>>> Please don't give (distinctly debatable) style tips as if they were
>>> hard and fast rules.  Not casting malloc has both benefits and
>>> drawbacks w.r.t. hiding bugs, and to suggest otherwise is to
>>> demonstrate incomplete understanding.
>>
>> Please explain when, in C, there is a "benefit" to casting the return from
>> malloc().
[...]
>
> Let's say I'm working on a programming project that uses multiple
> languages. And now let's say that the only (apparent) way I can get C
> to cooperate with the other programming languages is to cast the
> return value from malloc(). How would you get around avoiding casting
> the return from malloc()?

The fact that, at some point in your code, the value which was returned by 
malloc() will be passed to some function not written in C is irrelevant to 
the C code which calls malloc().

-- 
Kenneth Brody

[toc] | [prev] | [next] | [standalone]


#8752

FromJohn Gordon <gordon@panix.com>
Date2011-07-26 17:44 +0000
Message-ID<j0mudn$3sq$1@reader1.panix.com>
In reply to#8748
In <1c6b604c-cb47-4c76-b4ca-e26407e5d6a7@x19g2000prc.googlegroups.com> Chad <cdalten@gmail.com> writes:

> Let's say I'm working on a programming project that uses multiple
> languages. And now let's say that the only (apparent) way I can get C
> to cooperate with the other programming languages is to cast the
> return value from malloc(). How would you get around avoiding casting
> the return from malloc()?

If you're calling malloc() from within a module written in another
language, then you should use whatever mechanism that language provides
for coercing the return value of malloc() into a compatible representation.
But this isn't C casting, so this example is irrelevant.

If you're calling malloc() from within C code, the presence elsewhere in
your program of modules written in other languages is irrelevant.

In short, I don't see how other languages are relevant to this discussion.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [next] | [standalone]


#8753

FromAngel <angel+news@spamcop.net>
Date2011-07-26 17:45 +0000
Message-ID<slrnj2tva9.cfp.angel+news@pearlgates.net>
In reply to#8748
On 2011-07-26, Chad <cdalten@gmail.com> wrote:
> On Jul 26, 8:01?am, Kenneth Brody <kenbr...@spamcop.net> wrote:
>>
>> Please explain when, in C, there is a "benefit" to casting the return from
>> malloc().
>>
>> Unless you are using an ancient C compiler which predates "void *", there is
>> no good reason I can think of for casting the return from malloc(). ?And,
>> even on those ancient systems, the return was defined as "char *", making
>> the cast in the instant case redundant.
>>
>
> Let's say I'm working on a programming project that uses multiple
> languages. And now let's say that the only (apparent) way I can get C
> to cooperate with the other programming languages is to cast the
> return value from malloc(). How would you get around avoiding casting
> the return from malloc()?

I would say that you're either doing something very wrong or your
implementation is broken.


-- 
"C provides a programmer with more than enough rope to hang himself.
C++ provides a firing squad, blindfold and last cigarette."
- seen in comp.lang.c

[toc] | [prev] | [next] | [standalone]


#8757

FromSeebs <usenet-nospam@seebs.net>
Date2011-07-26 18:42 +0000
Message-ID<slrnj2u0gv.vkp.usenet-nospam@guild.seebs.net>
In reply to#8748
On 2011-07-26, Chad <cdalten@gmail.com> wrote:
> Let's say I'm working on a programming project that uses multiple
> languages.

Hmm.  Maybe?

> And now let's say that the only (apparent) way I can get C
> to cooperate with the other programming languages is to cast the
> return value from malloc().

This is "begging the question"; you're simply assuming that the cast
is necessary, without showing *how* it could be necessary.

> How would you get around avoiding casting
> the return from malloc()?

By not assuming something which isn't true.

Compile C code in C.  Don't compile C code in other languages.  If you need
to mix C and other languages, do it by separating C and other languages into
separate hunks of code.  Compile C with the C compiler, which does not need
casts for malloc.  If you need to call C from another language, do so by
using whatever tools that language has for calling C.

-s
-- 
Copyright 2011, all wrongs reversed.  Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.

[toc] | [prev] | [next] | [standalone]


#8759

FromBill Waddington <william.waddington@beezmo.com>
Date2011-07-26 11:55 -0700
Message-ID<3a3u27tof93eag7th8ig4501hpinktubqh@4ax.com>
In reply to#8757
On 26 Jul 2011 18:42:11 GMT, Seebs <usenet-nospam@seebs.net> wrote:

>On 2011-07-26, Chad <cdalten@gmail.com> wrote:
...
>
>> And now let's say that the only (apparent) way I can get C
>> to cooperate with the other programming languages is to cast the
>> return value from malloc().
>
>This is "begging the question"; you're simply assuming that the cast
>is necessary, without showing *how* it could be necessary.
...

Oh my.  Someone who knows what "begging the question" actaully means.
(Or actually meant, anyway...)

I salute you!

Bill
-- 
William D Waddington
william.waddington@beezmo.com
"Even bugs...are unexpected signposts on
the long road of creativity..." - Ken Burtch

[toc] | [prev] | [next] | [standalone]


#8763

Fromlawrence.jones@siemens.com
Date2011-07-26 18:11 -0400
Message-ID<ulq3g8-1hc.ln1@jones.homeip.net>
In reply to#8759
Bill Waddington <william.waddington@beezmo.com> wrote:
> 
> Oh my.  Someone who knows what "begging the question" actaully means.

There are still lots of us around, although we are greatly outnumbered.
-- 
Larry Jones

Hey Doc, for 10 bucks I'll make sure you see those kids in the
waiting room again real soon! -- Calvin

[toc] | [prev] | [next] | [standalone]


#8794

FromUno <Uno@example.invalid>
Date2011-07-27 20:58 -0600
Message-ID<99c1ipF14lU1@mid.individual.net>
In reply to#8763
On 07/26/2011 04:11 PM, lawrence.jones@siemens.com wrote:
> Bill Waddington<william.waddington@beezmo.com>  wrote:
>>
>> Oh my.  Someone who knows what "begging the question" actaully means.
>
> There are still lots of us around, although we are greatly outnumbered.

I think it was when the phrase left logic, a small part of mathematics, 
where it denoted that which bring proves a proposition by assuming it, 
and became something that would constantly flow out of the mouths of 
talking heads on tv, where it's taken to mean that which motivates 
another question which then oozes out of their mouths, so the usage is 
entirely different.

Current usage: "...which begs the question, does casey anthony support 
Obama?"

Old usage:  "That begs the question."  [Period.]  (Long awkward silence 
as all parties absorb that somebody's method is called out.)
-- 
Uno

[toc] | [prev] | [next] | [standalone]


#8940

Fromarnuld <sunrise@invalid.address>
Date2011-08-02 05:24 +0000
Message-ID<4e378a1a$0$310$14726298@news.sunsite.dk>
In reply to#8757
> On Tue, 26 Jul 2011 18:42:11 +0000, Seebs wrote:

> ..SNIP...

> Compile C code in C.  Don't compile C code in other languages.  If you
> need to mix C and other languages, do it by separating C and other
> languages into separate hunks of code.  Compile C with the C compiler,
> which does not need casts for malloc.  If you need to call C from
> another language, do so by using whatever tools that language has for
> calling C.

I have seen industrial programmers doing casts and saying that it will 
need to be compiled by C++ compiler. Many times I have seen this casting 
being done in projects where both C and C++ code is being used. Is this a 
wrong practice to cast when code has to be compiled by C++ compiler. And 
I don't see how can you call C from C++ (may be I am less experienced) ?





-- 
-- arnuld
www.LispMachine.Wordpress.com

[toc] | [prev] | [next] | [standalone]


#8943

FromIan Collins <ian-news@hotmail.com>
Date2011-08-02 18:10 +1200
Message-ID<99pimhFaa6U5@mid.individual.net>
In reply to#8940
On 08/ 2/11 05:24 PM, arnuld wrote:
>> On Tue, 26 Jul 2011 18:42:11 +0000, Seebs wrote:
>
>> ..SNIP...
>
>> Compile C code in C.  Don't compile C code in other languages.  If you
>> need to mix C and other languages, do it by separating C and other
>> languages into separate hunks of code.  Compile C with the C compiler,
>> which does not need casts for malloc.  If you need to call C from
>> another language, do so by using whatever tools that language has for
>> calling C.
>
> I have seen industrial programmers doing casts and saying that it will
> need to be compiled by C++ compiler. Many times I have seen this casting
> being done in projects where both C and C++ code is being used. Is this a
> wrong practice to cast when code has to be compiled by C++ compiler. And

You have to cast from void* in C++.

> I don't see how can you call C from C++ (may be I am less experienced) ?

If you couldn't, how could C++ use the C libraries?

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


#8946

FromKeith Thompson <kst-u@mib.org>
Date2011-08-02 00:03 -0700
Message-ID<lnhb60cn2l.fsf@nuthaus.mib.org>
In reply to#8940
arnuld <sunrise@invalid.address> writes:
>> On Tue, 26 Jul 2011 18:42:11 +0000, Seebs wrote:
>> ..SNIP...
>
>> Compile C code in C.  Don't compile C code in other languages.  If you
>> need to mix C and other languages, do it by separating C and other
>> languages into separate hunks of code.  Compile C with the C compiler,
>> which does not need casts for malloc.  If you need to call C from
>> another language, do so by using whatever tools that language has for
>> calling C.
>
> I have seen industrial programmers doing casts and saying that it will 
> need to be compiled by C++ compiler. Many times I have seen this casting 
> being done in projects where both C and C++ code is being used. Is this a 
> wrong practice to cast when code has to be compiled by C++ compiler. And 
> I don't see how can you call C from C++ (may be I am less experienced) ?

See section 32 of the "C++ FAQ Lite",
<http://www.parashift.com/c++-faq-lite/>.

There are circumstances where it makes sense to compile the same code as
C or as C++, but in most cases it's better to write C *or* C++, and take
advantage of C++'s interoperability features.

-- 
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"

[toc] | [prev] | [next] | [standalone]


#8948

FromJames Kuyper <jameskuyper@verizon.net>
Date2011-08-02 06:59 -0400
Message-ID<j18laq$6jt$1@dont-email.me>
In reply to#8940
On 08/02/2011 01:24 AM, arnuld wrote:
>> On Tue, 26 Jul 2011 18:42:11 +0000, Seebs wrote:
> 
>> ..SNIP...
> 
>> Compile C code in C.  Don't compile C code in other languages.  If you
>> need to mix C and other languages, do it by separating C and other
>> languages into separate hunks of code.  Compile C with the C compiler,
>> which does not need casts for malloc.  If you need to call C from
>> another language, do so by using whatever tools that language has for
>> calling C.
> 
> I have seen industrial programmers doing casts and saying that it will 
> need to be compiled by C++ compiler. Many times I have seen this casting 
> being done in projects where both C and C++ code is being used. Is this a 
> wrong practice to cast when code has to be compiled by C++ compiler. ...

If code needs to be compiled both as C and as C++, such casts are legal
in C and necessary in C++. But the need for such cross-compilable code
is often far less justified than it's proponents imagine.

> ... And 
> I don't see how can you call C from C++ (may be I am less experienced) ?

Calling a C routine from C++ requires only that the C++ code contain an
'extern "C"' declaration of the C function. It's the opposite direction
that's a little tricky. You cannot call arbitrary C++ functions from C.
The only C++ functions that can be called from C are those which were
declared 'extern "C"' in their C++ definitions. The 'extern "C"' must
NOT be present in the declaration of the function that is used by the C
code.

-- 
James Kuyper

[toc] | [prev] | [next] | [standalone]


#8958

FromSeebs <usenet-nospam@seebs.net>
Date2011-08-02 16:06 +0000
Message-ID<slrnj3g705.188p.usenet-nospam@guild.seebs.net>
In reply to#8940
On 2011-08-02, arnuld <sunrise@invalid.address> wrote:
>> On Tue, 26 Jul 2011 18:42:11 +0000, Seebs wrote:
>> Compile C code in C.  Don't compile C code in other languages.  If you
>> need to mix C and other languages, do it by separating C and other
>> languages into separate hunks of code.  Compile C with the C compiler,
>> which does not need casts for malloc.  If you need to call C from
>> another language, do so by using whatever tools that language has for
>> calling C.

> I have seen industrial programmers doing casts and saying that it will 
> need to be compiled by C++ compiler. Many times I have seen this casting 
> being done in projects where both C and C++ code is being used.

I have seen that too.

> Is this a 
> wrong practice to cast when code has to be compiled by C++ compiler.

No.  The wrong practice is to set things up so that C code has to be
compiled by a C++ compiler.

> And 
> I don't see how can you call C from C++ (may be I am less experienced) ?

Usually, it's very simple:  Declare something as extern "C", and then
compile it as C in a separate module, and then... just call it.  This
was intentionally made easy, which is why I think that code which "has to
be compiled as C++ too" is almost always a mistaken concept.

-s
-- 
Copyright 2011, all wrongs reversed.  Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.

[toc] | [prev] | [next] | [standalone]


#8756

FromSeebs <usenet-nospam@seebs.net>
Date2011-07-26 18:42 +0000
Message-ID<slrnj2u0c6.vkp.usenet-nospam@guild.seebs.net>
In reply to#8722
On 2011-07-26, gwowen <gwowen@gmail.com> wrote:
> Please don't give (distinctly debatable) style tips as if they were
> hard and fast rules.  Not casting malloc has both benefits and
> drawbacks w.r.t. hiding bugs, and to suggest otherwise is to
> demonstrate incomplete understanding.

Could you give an example of a case, in C, where not casting malloc hides
a bug that would have been caught had it been cast?

-s
-- 
Copyright 2011, all wrongs reversed.  Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.

[toc] | [prev] | [next] | [standalone]


#8770

FromNick Keighley <nick_keighley_nospam@hotmail.com>
Date2011-07-27 00:06 -0700
Message-ID<8ef48d47-7fd0-4afa-82ab-10aced7b8e3f@df3g2000vbb.googlegroups.com>
In reply to#8722
On Jul 26, 9:50 am, gwowen <gwo...@gmail.com> wrote:
> On Jul 26, 12:53 am, John Gordon <gor...@panix.com> wrote:
>
> >   char *testc(void)
>
> > >      char * pa;
> > >      pa = (char *)malloc (50);
>
> > Don't cast the return value of malloc.  There's no need, and it can hide
> > errors later on if you change the type of pa but forget to change the
> > cast.
>
> Please don't give (distinctly debatable) style tips as if they were
> hard and fast rules.  Not casting malloc has both benefits and
> drawbacks w.r.t. hiding bugs, and to suggest otherwise is to
> demonstrate incomplete understanding.

but on balance omitting the cast is the best option. Putting an
unnecesary cast in can hide bug. I don't see how leaving out the cast
can hide bugs.

The only good reason for casting malloc that I can see is that you're
compiling K&R C or using a C++ compiler. The Dinkum people who
maintain both C and C++ libraries reckon they have justification. But
hardly anyone else has.

[toc] | [prev] | [next] | [standalone]


#8942

FromGareth Owen <gwowen@gmail.com>
Date2011-08-02 06:58 +0100
Message-ID<87y5zce4mc.fsf@gmail.com>
In reply to#8770
Nick Keighley <nick_keighley_nospam@hotmail.com> writes:

> but on balance omitting the cast is the best option. 

For you, probably.  In which case I heartily encourage you to continue
with the style that works for you. But it is a balance, and in such
issues of *style* people can hold the other view.  Which was, after all,
my original point.

> I don't see how leaving out the cast can hide bugs.

It can.

[toc] | [prev] | [next] | [standalone]


#8945

FromKeith Thompson <kst-u@mib.org>
Date2011-08-02 00:01 -0700
Message-ID<lnlivccn6a.fsf@nuthaus.mib.org>
In reply to#8942
Gareth Owen <gwowen@gmail.com> writes:
> Nick Keighley <nick_keighley_nospam@hotmail.com> writes:
>
>> but on balance omitting the cast is the best option. 
>
> For you, probably.  In which case I heartily encourage you to continue
> with the style that works for you. But it is a balance, and in such
> issues of *style* people can hold the other view.  Which was, after all,
> my original point.
>
>> I don't see how leaving out the cast can hide bugs.
>
> It can.

Perhaps in very rare circumstances, far rarer than the circumstances in
which adding the cast can hide bugs.

-- 
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"

[toc] | [prev] | [next] | [standalone]


#9030

FromGareth Owen <gwowen@gmail.com>
Date2011-08-05 06:22 +0100
Message-ID<87sjpg77q8.fsf@gmail.com>
In reply to#8945
Keith Thompson <kst-u@mib.org> writes:

> Gareth Owen <gwowen@gmail.com> writes:
>> Nick Keighley <nick_keighley_nospam@hotmail.com> writes:
>>
>>> but on balance omitting the cast is the best option. 
>>
>> For you, probably.  In which case I heartily encourage you to continue
>> with the style that works for you. But it is a balance, and in such
>> issues of *style* people can hold the other view.  Which was, after all,
>> my original point.
>>
>>> I don't see how leaving out the cast can hide bugs.
>>
>> It can.
>
> Perhaps in very rare circumstances, far rarer than the circumstances in
> which adding the cast can hide bugs.

Rarer, for you, probably.  In which case I heartily encourage you to
continue with the style that works for you. But it is a balance, and in
such issues of *style* people can hold the other view.  Which was, after
all, my original point.

[toc] | [prev] | [next] | [standalone]


#9032

FromKeith Thompson <kst-u@mib.org>
Date2011-08-04 23:54 -0700
Message-ID<lnwresbb6a.fsf@nuthaus.mib.org>
In reply to#9030
Gareth Owen <gwowen@gmail.com> writes:
> Keith Thompson <kst-u@mib.org> writes:
>> Gareth Owen <gwowen@gmail.com> writes:
>>> Nick Keighley <nick_keighley_nospam@hotmail.com> writes:
>>>
>>>> but on balance omitting the cast is the best option. 
>>>
>>> For you, probably.  In which case I heartily encourage you to continue
>>> with the style that works for you. But it is a balance, and in such
>>> issues of *style* people can hold the other view.  Which was, after all,
>>> my original point.
>>>
>>>> I don't see how leaving out the cast can hide bugs.
>>>
>>> It can.
>>
>> Perhaps in very rare circumstances, far rarer than the circumstances in
>> which adding the cast can hide bugs.
>
> Rarer, for you, probably.  In which case I heartily encourage you to
> continue with the style that works for you. But it is a balance, and in
> such issues of *style* people can hold the other view.  Which was, after
> all, my original point.

If you want to argue that it's a style point, we can just agree
to disagree.  But if you're going to argue that leaving out the
cast can hide bugs, and that that's a reason to use a cast, that's
a practical matter, and on that point I believe you're wrong.

-- 
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"

[toc] | [prev] | [next] | [standalone]


Page 4 of 7 — ← Prev page 1 2 3 [4] 5 6 7  Next page →

Back to top | Article view | comp.lang.c


csiph-web