comp.lang.c - 25 new messages in 8 topics - digest
comp.lang.c
http://groups.google.com/group/comp.lang.c?hl=en
Today's topics:
* defining a boolean type - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c/t/fcfa31f0e0473e4f?hl=en
* free c text book advice.. - 6 messages, 5 authors
http://groups.google.com/group/comp.lang.c/t/adf51d19d9b07faf?hl=en
* CRT Get Module Directory - GetModule Name ?? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/f0d4960792df2d7d?hl=en
* Warning to newbies - 9 messages, 4 authors
http://groups.google.com/group/comp.lang.c/t/9597fd702985dff4?hl=en
* Macro Mystery ... help? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/edb83374439ae2ad?hl=en
* memset() on a struct or union - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/e41e9c30b0f7a050?hl=en
* MySQL connector/driver behaviour with Visual C++ CLR/CLI project - 2
messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/738ca35dc8623177?hl=en
* Pointer Question II - The Rebirth - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/17bf09bb220a8480?hl=en
==============================================================================
TOPIC: defining a boolean type
http://groups.google.com/group/comp.lang.c/t/fcfa31f0e0473e4f?hl=en
==============================================================================
== 1 of 3 ==
Date: Tues, Feb 2 2010 4:55 pm
From: "Rod Pemberton"
"Seebs" <usenet-nospam@seebs.net> wrote in message
news:slrnhmf210.hkn.usenet-nospam@guild.seebs.net...
> On 2010-02-02, Rod Pemberton <do_not_have@havenone.cmm> wrote:
> >> You can only define a single value as TRUE (or true). The most
> >> obvious value to use is 1.
>
> > Is it?
>
> Yes.
>
> >Isn't _obvious_ it should -1? (-1 a.k.a. all bits set)
>
> Not really "obvious".
I was discretely pointing out KT still has no experience with assembly or
the implementation of C using assembly. All the world is ADA...
> Interestingly, the one other person I've seen argue
> that was Edward Nilges. :)
That just means you haven't used other languages. FORTH used 0 and 1 for
false and true, respectively for the first two standard versions: fig-FORTH
and FORTH-77. In FORTH-83, they converted to 0 and -1 for false and true,
respectively. That was 1983: 27 years ago. The reason was the same as for
assembly. Logical operations must be constructed from bitwise operations in
most assembly.
> Here's my thought: Consider a single bit. It's either zero or one.
>
> The non-zero value is 1. Otherwise, you have the problem that
>
> ((unsigned short) true == (int) true)
>
> might be untrue.
Did I miss something? C has that problem currently. So, what's your point?
True is non-zero. If true as non-zero is larger than a C byte, true could
be truncated via a cast from a non-zero value to a zero value. It's only if
you use a #define to specify a value for TRUE that can't be truncated that
"((unsigned short) true == (int) true)" will not be untrue.
> > That's true. But, using 1 as the only valid value "true" means you can
only
> > use it within logical operations. What if you forget and use it with a
> > binary operation? Shouldn't a value of true be chosen to work with
_both_
> > binary and logical operations? Wouldn't that be wise?
>
> I don't think it works out that way. If you pick -1, then
> (x & true)
> is always true if x is non-zero -- but
Correct.
> (x & true) & (y & true)
> might not be non-zero even if both x and y are non-zero.
For -1 as a true value, true. But, (x&true) and (y&true) have both worked
properly using true with a binary operation. It's the later operation,
which doesn't use true, that fails. This is no different than x&y resulting
in zero for certain non-zero binary values.
> So I don't much like the attempt to make the first work, since if the
first
> works, you might mistakenly expect the second to work.
...
> > I don't agree. I want my value for "true" to work correctly for both
binary
> > and logical operations as a non-false value.
>
> > if(i&TRUE)
> > printf("TRUE succeeds as binary-true.\n");
>
> That doesn't make any sense, though. How is "i & TRUE" being non-zero
making
> TRUE a "binary-true"?
From the binary and (&) ... meaning that TRUE works as true with a binary
operation. Using a value of 1 for true will fail to result in true with a
binary and (&) for even values of 'i'.
> With the usual value, if (x & true) is non-zero, (x & true) == true.
(x&true) results in true only for odd values of x. So, (x&true)==true only
reports odd's (non-portably). It produces a zero result for half.
If true is non-zero and x is non-zero, wouldn't you like a non-zero result
for (x&true)? Just like (x&&true)?
> With the usual value, if (x & true) is non-zero, (x & true) == true.
> With yours, it isn't.
However, I'm not sure why anyone would do a binary comparison of a result
with true when you can test this directly via an if()...
RP
== 2 of 3 ==
Date: Tues, Feb 2 2010 5:38 pm
From: Keith Thompson
"Rod Pemberton" <do_not_have@havenone.cmm> writes:
> "Seebs" <usenet-nospam@seebs.net> wrote in message
> news:slrnhmf210.hkn.usenet-nospam@guild.seebs.net...
>> On 2010-02-02, Rod Pemberton <do_not_have@havenone.cmm> wrote:
>> >> You can only define a single value as TRUE (or true). The most
>> >> obvious value to use is 1.
>>
>> > Is it?
>>
>> Yes.
>>
>> >Isn't _obvious_ it should -1? (-1 a.k.a. all bits set)
>>
>> Not really "obvious".
>
> I was discretely pointing out KT still has no experience with assembly or
> the implementation of C using assembly. All the world is ADA...
Assuming "KT" refers to me, I don't know what you're talking about,
or why. This isn't about what experience I personally may or may
not have. As for ADA, the correct spelling is Ada, and your remark
is neither true nor relevant.
--
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 3 ==
Date: Tues, Feb 2 2010 7:37 pm
From: Joe Wright
Rod Pemberton wrote:
> "Seebs" <usenet-nospam@seebs.net> wrote in message
> news:slrnhmf210.hkn.usenet-nospam@guild.seebs.net...
>> On 2010-02-02, Rod Pemberton <do_not_have@havenone.cmm> wrote:
>>>> You can only define a single value as TRUE (or true). The most
>>>> obvious value to use is 1.
>>> Is it?
>> Yes.
>>
>>> Isn't _obvious_ it should -1? (-1 a.k.a. all bits set)
>> Not really "obvious".
>
> I was discretely pointing out KT still has no experience with assembly or
> the implementation of C using assembly. All the world is ADA...
>
>> Interestingly, the one other person I've seen argue
>> that was Edward Nilges. :)
>
> That just means you haven't used other languages. FORTH used 0 and 1 for
> false and true, respectively for the first two standard versions: fig-FORTH
> and FORTH-77. In FORTH-83, they converted to 0 and -1 for false and true,
> respectively. That was 1983: 27 years ago. The reason was the same as for
> assembly. Logical operations must be constructed from bitwise operations in
> most assembly.
>
>> Here's my thought: Consider a single bit. It's either zero or one.
>>
>> The non-zero value is 1. Otherwise, you have the problem that
>>
>> ((unsigned short) true == (int) true)
>>
>> might be untrue.
>
> Did I miss something? C has that problem currently. So, what's your point?
>
> True is non-zero. If true as non-zero is larger than a C byte, true could
> be truncated via a cast from a non-zero value to a zero value. It's only if
> you use a #define to specify a value for TRUE that can't be truncated that
> "((unsigned short) true == (int) true)" will not be untrue.
>
>>> That's true. But, using 1 as the only valid value "true" means you can
> only
>>> use it within logical operations. What if you forget and use it with a
>>> binary operation? Shouldn't a value of true be chosen to work with
> _both_
>>> binary and logical operations? Wouldn't that be wise?
>> I don't think it works out that way. If you pick -1, then
>> (x & true)
>> is always true if x is non-zero -- but
>
> Correct.
>
>> (x & true) & (y & true)
>> might not be non-zero even if both x and y are non-zero.
>
> For -1 as a true value, true. But, (x&true) and (y&true) have both worked
> properly using true with a binary operation. It's the later operation,
> which doesn't use true, that fails. This is no different than x&y resulting
> in zero for certain non-zero binary values.
>
>> So I don't much like the attempt to make the first work, since if the
> first
>> works, you might mistakenly expect the second to work.
> ...
>
>>> I don't agree. I want my value for "true" to work correctly for both
> binary
>>> and logical operations as a non-false value.
>>> if(i&TRUE)
>>> printf("TRUE succeeds as binary-true.\n");
>> That doesn't make any sense, though. How is "i & TRUE" being non-zero
> making
>> TRUE a "binary-true"?
>
> From the binary and (&) ... meaning that TRUE works as true with a binary
> operation. Using a value of 1 for true will fail to result in true with a
> binary and (&) for even values of 'i'.
>
>> With the usual value, if (x & true) is non-zero, (x & true) == true.
>
> (x&true) results in true only for odd values of x. So, (x&true)==true only
> reports odd's (non-portably). It produces a zero result for half.
>
> If true is non-zero and x is non-zero, wouldn't you like a non-zero result
> for (x&true)? Just like (x&&true)?
>
>> With the usual value, if (x & true) is non-zero, (x & true) == true.
>> With yours, it isn't.
>
> However, I'm not sure why anyone would do a binary comparison of a result
> with true when you can test this directly via an if()...
>
>
> RP
>
>
int false(int v) {
return v == 0;
}
int true(int v) {
return false(v) == 0;
}
--
Joe Wright
"If you rob Peter to pay Paul you can depend on the support of Paul."
==============================================================================
TOPIC: free c text book advice..
http://groups.google.com/group/comp.lang.c/t/adf51d19d9b07faf?hl=en
==============================================================================
== 1 of 6 ==
Date: Tues, Feb 2 2010 5:14 pm
From: Richard Heathfield
jacob navia wrote:
> Rob Kendrick a écrit :
>
>> As a native speaker, I don't see this. What I do see is people being
>> needlessly and pointlessly argumentative and inflammatory for the sake
>> of it.
>>
>
> OK. Mr native.
>
> If Heathfield did NOT recommend that book WHAT did he do?
I mentioned its existence and gave a URL from which it can be
downloaded. I also made it clear that I had not read the book, but had
only glimpsed at it briefly and, in that brief glimpse, had seen no
obvious screw-ups.
Only a complete idiot would consider that a recommendation. This
newsgroup appears to have no shortage of idiots.
<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
== 2 of 6 ==
Date: Tues, Feb 2 2010 5:40 pm
From: Rob Kendrick
On Tue, 02 Feb 2010 22:45:21 +0100
jacob navia <jacob@spamsink.net> wrote:
> OK. Mr native.
>
> If Heathfield did NOT recommend that book WHAT did he do?
>
> A asked "I need a free book about C"
> B answered "Use XXX" (with some caveats). He gives the URL and says
> it doesn't look bad at first sight.
Again with the needlessly inflammatory language. Come back when you've
calmed down again, and I'll explain to you what everything you've
snipped means.
B.
== 3 of 6 ==
Date: Tues, Feb 2 2010 5:46 pm
From: Richard
Rob Kendrick <nntp@rjek.com> writes:
> On Tue, 02 Feb 2010 22:45:21 +0100
> jacob navia <jacob@spamsink.net> wrote:
>
>> OK. Mr native.
>>
>> If Heathfield did NOT recommend that book WHAT did he do?
>>
>> A asked "I need a free book about C"
>> B answered "Use XXX" (with some caveats). He gives the URL and says
>> it doesn't look bad at first sight.
>
> Again with the needlessly inflammatory language. Come back when you've
> calmed down again, and I'll explain to you what everything you've
> snipped means.
>
> B.
What inflammatory language? He is getting frustrated that you seem
unable to understand the language you claim to be so masterful of.
If someone asks for a book online and someone else says "try this" then
that IS a recommendation. Now if you want to continue to make
yourself look like an arse then please do, but don't expect anyone to
take you too seriously.
--
"Avoid hyperbole at all costs, its the most destructive argument on
the planet" - Mark McIntyre in comp.lang.c
== 4 of 6 ==
Date: Tues, Feb 2 2010 5:54 pm
From: Rob Kendrick
On Wed, 03 Feb 2010 02:46:20 +0100
Richard <rgrdev_@gmail.com> wrote:
> What inflammatory language? He is getting frustrated that you seem
> unable to understand the language you claim to be so masterful of.
It seems you're having trouble with the language, too. I never claimed
any such thing, and I'm sure you know that. And if you can't see the
tone in which Jacob's post was written, I have a small amount of pity
for you.
> If someone asks for a book online and someone else says "try this"
> then that IS a recommendation. Now if you want to continue to make
> yourself look like an arse then please do, but don't expect anyone to
> take you too seriously.
And of course, if all he said was "try this", you might be right. In
fact, he didn't even say "try this", he simply provided a link
somewhere, along with a disclaimer about not knowing if it was any good.
http://en.wikipedia.org/wiki/LSD
Caveat: I've not tried it, so I have no idea whether it's any good.
B.
== 5 of 6 ==
Date: Tues, Feb 2 2010 9:20 pm
From: cri@tiac.net (Richard Harter)
On Wed, 03 Feb 2010 01:14:01 +0000, Richard Heathfield
<rjh@see.sig.invalid> wrote:
[snip]
>Only a complete idiot would consider that a recommendation. This
>newsgroup appears to have no shortage of idiots.
This sort of thing is one reason why you raise people's hackles.
Calling people idiots, stupid, losers and the like is common
enough among bright progammers. It's a trap. People do not
respond well to perceived arrogance and condescension.
Richard Harter, cri@tiac.net
http://home.tiac.net/~cri, http://www.varinoma.com
Infinity is one of those things that keep philosophers busy when they
could be more profitably spending their time weeding their garden.
== 6 of 6 ==
Date: Tues, Feb 2 2010 9:37 pm
From: Seebs
On 2010-02-03, Richard Harter <cri@tiac.net> wrote:
> On Wed, 03 Feb 2010 01:14:01 +0000, Richard Heathfield
><rjh@see.sig.invalid> wrote:
>>Only a complete idiot would consider that a recommendation. This
>>newsgroup appears to have no shortage of idiots.
> This sort of thing is one reason why you raise people's hackles.
> Calling people idiots, stupid, losers and the like is common
> enough among bright progammers. It's a trap. People do not
> respond well to perceived arrogance and condescension.
I gotta second that one. I can understand being angry with Jacob for
what he's been saying, but I don't think it makes him a complete idiot.
I disagree with him, but I can see someone reasonably assuming that
offering a link in response to a query is at least *normally* a
recommendation. I think the disclaimers adequately dispelled that, but...
-s
--
Copyright 2010, 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!
==============================================================================
TOPIC: CRT Get Module Directory - GetModule Name ??
http://groups.google.com/group/comp.lang.c/t/f0d4960792df2d7d?hl=en
==============================================================================
== 1 of 2 ==
Date: Tues, Feb 2 2010 5:50 pm
From: "BGB / cr88192"
"C++8x" <expert.cpp@gmail.com> wrote in message
news:19991438-8a56-48de-a479-037ea224a1e7@b1g2000prc.googlegroups.com...
On Feb 2, 3:22 pm, Keith Thompson <ks...@mib.org> wrote:
>
> There is nothing in standard C that will do what you're trying to do.
> The C standard doesn't even mention DLLs. The closest thing to what
> you're looking for is probably argv[0], which *usually* points to a
> string containing the name of the program.
<--
Thanks for reply!
I will ask the windows group, but I guess the windows way is to call
an Win32 API function. But I don't want to #include <windows.h> for
that. Though, just off the top of my head: I can probably declare
needed API function, and link with one of windows' dll's (kernel32.dll
or user32.dll or whatever) and make sure calling conventions
difference between my c dll and the API function is the same. And name
mangling might be the issue...
But, I don't want to deal with Windows API here.
-->
use it or don't use it...
ugly hackery like this is ill-advised...
note that some common ways to deal with portability issues are:
put OS-specific code in separate files, and only include them in the build
for a particular OS (downside: this complicates building the project);
make use of the preprocessor ("#ifdef", "#ifndef", "

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home