469,572 Members | 1,629 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

Struct size

Can anyone tell me the best way to find out the size of a struct, without
using the sizeof function? I'm currently thinking of:

struct foo s[2];
int size_of_foo = (char *)&s[1] - (char *)s;

but is there a more elegant way (e.g. requiring no memory).

Thanks in advance!
-Jeff
************************************************** ****************************
* *
* JEFF P. SYVERSON, PHD *
* Senior Systems Engineer *
* *
* CITRIC SOLUTIONS INC. -- 2495 SUNRISE BLVD -- RANCHO CORDOVA -- CA *
* *
************************************************** ****************************

This email and any file attachments(s) are confidential, may be legally
privileged, and are intended solely for use by the identified recipient(s). If
you received the email in error, please notify the sender and delete the
message and any copies completely from your computer. Dissemination,
distribution, or copying of this communication, in whole or in part, by any
unintended or unauthorized recipient is prohibited and may subject you to
liability under 18 U.S.C. sec. 2511. Citric Solutions, Inc. assumes no
liability and makes no warranties or representations that the email or any
file attachments are totally secure and/or virus free. The recipient is
advised to check for viruses prior to opening any file attached to the email.
Statements contained in the email or any file attachment may not be authorized
or endorsed by Citric Solutions, Inc. Citric Solutions, Inc. accepts no
liability, whether in contract, tort, or equity, for any unauthorized
statement or offer of contract communicated in the email or any file attached
by the sender.
Sep 20 '07 #1
42 2723
Jeff P. Syverson wrote:
Can anyone tell me the best way to find out the size of a struct, without
using the sizeof function? I'm currently thinking of:

struct foo s[2];
int size_of_foo = (char *)&s[1] - (char *)s;

but is there a more elegant way (e.g. requiring no memory).
Why, sizeof is there for a good reason
Thanks in advance!
-Jeff
************************************************** ****************************
* *
* JEFF P. SYVERSON, PHD *
* Senior Systems Engineer *
* *
* CITRIC SOLUTIONS INC. -- 2495 SUNRISE BLVD -- RANCHO CORDOVA -- CA *
* *
************************************************** ****************************

This email and any file attachments(s) are confidential, may be legally
privileged, and are intended solely for use by the identified recipient(s). If
you received the email in error, please notify the sender and delete the
message and any copies completely from your computer. Dissemination,
distribution, or copying of this communication, in whole or in part, by any
unintended or unauthorized recipient is prohibited and may subject you to
liability under 18 U.S.C. sec. 2511. Citric Solutions, Inc. assumes no
liability and makes no warranties or representations that the email or any
file attachments are totally secure and/or virus free. The recipient is
advised to check for viruses prior to opening any file attached to the email.
Statements contained in the email or any file attachment may not be authorized
or endorsed by Citric Solutions, Inc. Citric Solutions, Inc. accepts no
liability, whether in contract, tort, or equity, for any unauthorized
statement or offer of contract communicated in the email or any file attached
by the sender.
Surly you can trim all this nonsense?

--
Ian Collins.
Sep 20 '07 #2
Jeff P. Syverson said:
Can anyone tell me the best way to find out the size of a struct, without
using the sizeof function?
The designer of the C programming language, Dennis Ritchie, is one smart
cookie, and he saw at once, all those years ago, that it would simply not
be right for people to use a sizeof function to establish the sizes of
types and expressions of those types. So he invented a keyword, sizeof,
thus making it illegal (nowadays, we'd say "a constraint violation
requiring a diagnostic message") to even /write/ a function named sizeof.
You may therefore rest assured that it is impossible to use a sizeof
function (let alone *the* sizeof function) in C.

Incidentally, as well as rendering the creating of a function named sizeof
impossible, the sizeof keyword has a little-known secondary use - it
yields the size of its operand, in bytes. What's more, it evaluates this
size during the translation of the program, rather than waiting until
runtime, which is a nice touch.

So the answer to your question is this: the best way to find out the size
of a struct, without using the sizeof function, is to use the sizeof
keyword.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 20 '07 #3
Ian Collins <ia******@hotmail.comwrote:
>Jeff P. Syverson wrote:
>... without using the sizeof function? ...
....
>Why, sizeof is there for a good reason
....
> [And then the grand finale, 15 lines of legalese]

Surly you can trim all this nonsense?
To all those who find this unusual, consider yourselves lucky you were
not forced to do the same.
There are companies that require this type of statements on outgoing
email. That text may have been added automatically by his employer
email system, with or without Mr. Syverson's consent.

Roberto Waltman

[ Please reply to the group,
return address is invalid ]
Sep 20 '07 #4
Eric Sosman said:

<snip>
One of the improvements should be the ability to
recognize and reject stupid requirements (another mark of
seniority and experience). "What's the most elegant and
efficient way to distinguish even numbers from odds without
using the notion of `two'?"
Another important attribute is the ability to meet stupid requirements
easily, quickly, and with a straight face:

int is_odd(unsigned long n)
{
return n & 1;
}

int is_even(unsigned long n)
{
return !is_odd(n);
}

Some fast talking may also be required.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 20 '07 #5
On Sep 19, 10:18 pm, Roberto Waltman <use...@rwaltman.netwrote:
To all those who find this unusual, consider yourselves lucky you were
not forced to do the same.
There are companies that require this type of statements on outgoing
email. That text may have been added automatically by his employer
email system, with or without Mr. Syverson's consent.
IMO that is one of the few excellent reasons to use Google (or
anything other than one's employer e-mail) for posting. Given the
terms listed in the boilerplate, one could argue that Google is itself
an "unintended recipient" and therefore criminally liable for
"disseminating" the original post, not to mention a hapless responder
who quotes the original post.

Sep 20 '07 #6
Richard Heathfield <rj*@see.sig.invalidwrites:
[...]
The designer of the C programming language, Dennis Ritchie, is one smart
cookie, and he saw at once, all those years ago, that it would simply not
be right for people to use a sizeof function to establish the sizes of
types and expressions of those types. So he invented a keyword, sizeof,
thus making it illegal (nowadays, we'd say "a constraint violation
requiring a diagnostic message") to even /write/ a function named sizeof.
You may therefore rest assured that it is impossible to use a sizeof
function (let alone *the* sizeof function) in C.
[...]

A quibble: Attempting to declare a function named "sizeof" is not a
constraint violation requiring a diagnostic message. It's a syntax
rule violation requiring a diagnostic message.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Sep 20 '07 #7
Keith Thompson said:
Richard Heathfield <rj*@see.sig.invalidwrites:
[...]
>The designer of the C programming language, Dennis Ritchie, is one smart
cookie, and he saw at once, all those years ago, that it would simply
not be right for people to use a sizeof function to establish the sizes
of types and expressions of those types. So he invented a keyword,
sizeof, thus making it illegal (nowadays, we'd say "a constraint
violation requiring a diagnostic message") to even /write/ a function
named sizeof. You may therefore rest assured that it is impossible to
use a sizeof function (let alone *the* sizeof function) in C.
[...]

A quibble: Attempting to declare a function named "sizeof" is not a
constraint violation requiring a diagnostic message. It's a syntax
rule violation requiring a diagnostic message.
In C89, it violates the constraint in 3.1.2:

"In translation phases 7 and 8, an identifier shall not consist of
the same sequence of characters as a keyword."

In C99, this constraint seems to have disappeared. So we're both right. :-)

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 20 '07 #8
"Jeff P. Syverson" <no****@nospam.comwrites:
Can anyone tell me the best way to find out the size of a struct, without
using the sizeof function? I'm currently thinking of:

struct foo s[2];
int size_of_foo = (char *)&s[1] - (char *)s;

but is there a more elegant way (e.g. requiring no memory).
It's easy to make the mistake of thinking that 'sizeof' is a function.
In fact, it's an operator. It's unusual in that it's the only
operator whose name is a keyword (which looks like an identifier)
rather than a token consisting of one or more punctuation marks.

Yes, I can think of a way to simplify your code slightly (you don't
need a 2-element array), but there's not much point in doing so.
You're asking the equivalent of "What's the best way to drive a nail
without using a hammer?", or "What's the best way to steer my car
without using the steering wheel?". In all three cases, there's
probably an answer, but the real answer is to use the right tool for
the job in the first place.

Explain *why* you don't want to use the sizeof operator, and perhaps
we can help. We get this question fairly frequently; it's usually a
homework question. The only valid reason I can think of to compute
the size of a struct without using 'sizeof' is to show how ugly the
resulting code is, demonstrating that including 'sizeof' as a built-in
operator was a really good idea.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Sep 20 '07 #9
Roberto Waltman <us****@rwaltman.netwrites:
Ian Collins <ia******@hotmail.comwrote:
>>Jeff P. Syverson wrote:
>>... without using the sizeof function? ...
...
>>Why, sizeof is there for a good reason
...
>> [And then the grand finale, 15 lines of legalese]

Surly you can trim all this nonsense?

To all those who find this unusual, consider yourselves lucky you were
not forced to do the same.
There are companies that require this type of statements on outgoing
email. That text may have been added automatically by his employer
email system, with or without Mr. Syverson's consent.
But he's using an aioe.org NNTP server.

Mr. Syverson: If at all possible, please avoid including the huge
legal disclaimer in any future postings here. Usenet messages are not
e-mail; the disclaimer is meaningless (but I'm not a lawyer). If for
some reason you absolutely must include the disclaimer, please precede
it and your signature with a delimiter line consisting of "-- ".

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Sep 20 '07 #10
On Sep 19, 9:26 pm, Richard <rgr...@gmail.comwrote:
Why are you here? Will you post this to every question which is already
answered in google? Or did you just want to put your hand up and
announce yourself unwilling to help?
Well, I suppose it would have been more helpful if I had troubled
myself to locate the relevant posts myself, but it's not *my*
question. If you answer a man's question, he gets an A/a raise/the
warm glow of knowledge one time, but if you teach him to search the
Google archives, he can experience that euphoria for a lifetime, and
with no further tiresome importunement upon the group to boot.

Sep 20 '07 #11
Roberto Waltman wrote:
Ian Collins <ia******@hotmail.comwrote:
>Jeff P. Syverson wrote:
>>... without using the sizeof function? ...
...
>Why, sizeof is there for a good reason
...
>> [And then the grand finale, 15 lines of legalese]

Surly you can trim all this nonsense?

To all those who find this unusual, consider yourselves lucky you
were not forced to do the same. There are companies that require
this type of statements on outgoing email. That text may have been
added automatically by his employer email system, with or without
Mr. Syverson's consent.
However that was a Usenet entry, not e-mail. It should not have
gone through an email system at all. Of course his organization
may not be aware of all this, and still have forced the ridiculous
appendage, without even a sig marker.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Sep 20 '07 #12
Eric Sosman wrote:
Richard wrote:
.... snip ...
>
>A Senior Systems Engineer doesn't have to know any C.

Twenty years ago, no. And twenty years from now, perhaps not.
But today, right now, a systems engineer ignorant of C -- even of
the bare basics of C -- ought not to carry the label "senior."
>And clearly he has an ulterior motive for not wanting to use
sizeof. I suspect home work for an "impprovement" course.

Ayeh. One of the improvements should be the ability to recognize
and reject stupid requirements (another mark of seniority and
experience). "What's the most elegant and efficient way to
distinguish even numbers from odds without using the notion of
`two'?"
And maybe someone should suggest that he get and read K&R2 and/or
the C standard. The links in my sig may help.

--
Some useful references about C:
<http://www.ungerhu.com/jxh/clc.welcome.txt>
<http://www.eskimo.com/~scs/C-faq/top.html (C-faq)
<http://benpfaff.org/writings/clc/off-topic.html>
<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/(C99 std)
<http://www.dinkumware.com/refxc.html (C-library}
<http://gcc.gnu.org/onlinedocs/ (GNU docs)
<http://clc-wiki.net/wiki/C_community:comp.lang.c:Introduction>

--
Posted via a free Usenet account from http://www.teranews.com

Sep 20 '07 #13
On Thu, 20 Sep 2007 03:12:41 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
>Eric Sosman said:

<snip>
>One of the improvements should be the ability to
recognize and reject stupid requirements (another mark of
seniority and experience). "What's the most elegant and
efficient way to distinguish even numbers from odds without
using the notion of `two'?"

Another important attribute is the ability to meet stupid requirements
easily, quickly, and with a straight face:

int is_odd(unsigned long n)
{
return n & 1;
}
Quick.
>int is_even(unsigned long n)
{
return !is_odd(n);
}
Easy.
>Some fast talking may also be required.
Fortunately, C99 introduced the keyword "inline". As a result, in the
above code, "Easy" should equate to "Quick"--just insert "inline" in
its proper place. It follows that no fast talking should be required.
Unless of course those requirement writers are savvy enough to ask
which C99 compiler you're using. Perhaps some fast-talking may well be
required.

Requirement writer: "Can you make it quick and easy"?
Programmer: "Yes".
Requirement writer: "What does that require"?
Programmer: "A C99 compiler".
Requirement writer: "That should be no problem, right, given that
we're in the year 2007"?
Programmer: "Yes, of course".
Requirement writer: "I'm curious, which C99 compiler will you be
using"?
Programmer: "Did you see that Bear's game last night"?

Regards
--
jay
Sep 20 '07 #14
"Eric Sosman" <es*****@ieee-dot-org.invalidschrieb im Newsbeitrag
news:3Y******************************@comcast.com. ..
a PhD in Experimental Theology
ROTFL, hilarious! Thanks for that, you made my day

bye, Jojo
Sep 20 '07 #15
On Thu, 20 Sep 2007 03:12:41 +0000, Richard Heathfield wrote:
Eric Sosman said:
[snip] "What's the most elegant and
>efficient way to distinguish even numbers from odds without
using the notion of `two'?"
return n & 1;
How do you explain what & does without using the notion of 'two'?
:-)
A better way:
n is even: ∃x ∈ ℤ ∣ x + x = n
n is odd: n ∈ ℤ ⋀ ¬(n is even)

(Yes, there are two x's in the sum above, but this doesn't use the
notion of 'two' anymore than the sentence "I am happy." uses the
notion of 'three' because it has three words, right?)
--
Army1987 (Replace "NOSPAM" with "email")
If you're sending e-mail from a Windows machine, turn off Microsoft's
stupid “Smart Quotes” feature. This is so you'll avoid sprinkling garbage
characters through your mail. -- Eric S. Raymond and Rick Moen

Sep 20 '07 #16
On Wed, 19 Sep 2007 21:49:25 -0400, Eric Sosman wrote:
Jeff P. Syverson wrote:
>Can anyone tell me the best way to find out the size of a struct, without
using the sizeof function? [...]

* JEFF P. SYVERSON, PHD *
* Senior Systems Engineer *
[... twenty-four lines of boilerplate all told]
OMG. I had not even noticed it. The last line in my screenful was
the blank line below -Jeff, and I didn't even consider scrolling
down.
--
Army1987 (Replace "NOSPAM" with "email")
If you're sending e-mail from a Windows machine, turn off Microsoft's
stupid “Smart Quotes” feature. This is so you'll avoid sprinkling garbage
characters through your mail. -- Eric S. Raymond and Rick Moen

Sep 20 '07 #17
Army1987 said:
On Thu, 20 Sep 2007 03:12:41 +0000, Richard Heathfield wrote:
>Eric Sosman said:
[snip] "What's the most elegant and
>>efficient way to distinguish even numbers from odds without
using the notion of `two'?"
> return n & 1;

How do you explain what & does without using the notion of 'two'?
:-)
Yields the result of performing a bitwise AND of all its operands.
A better way:
n is even: ?x ? ? ? x + x = n
n is odd: n ? ? ? (n is even)

(Yes, there are two x's in the sum above, but this doesn't use the
notion of 'two' anymore than the sentence "I am happy." uses the
notion of 'three' because it has three words, right?)
For the same reason, return n & 1; doesn't use the notion of "three".

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 20 '07 #18
Eric Sosman wrote:
>
Richard wrote:
[...]
And clearly he has an ulterior
motive for not wanting to use sizeof. I suspect home work for an
"impprovement" course.

Ayeh. One of the improvements should be the ability to
recognize and reject stupid requirements (another mark of
seniority and experience). "What's the most elegant and
efficient way to distinguish even numbers from odds without
using the notion of `two'?"
But first, define "even" and "odd" without using the notion of "two".

Then, define "prime" without using the notion of "division".

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Sep 20 '07 #19
In article <46***************@spamcop.net>,
Kenneth Brody <ke******@spamcop.netwrote:
>But first, define "even" and "odd" without using the notion of "two".
Easily done, recursively.
>Then, define "prime" without using the notion of "division".
Doesn't the usual definition not use division? A natural number is
prime if it is not the product of two natural other than itself and
one.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Sep 20 '07 #20
Kenneth Brody said:
Eric Sosman wrote:
>>
Richard wrote:
[...]
And clearly he has an ulterior
motive for not wanting to use sizeof. I suspect home work for an
"impprovement" course.

Ayeh. One of the improvements should be the ability to
recognize and reject stupid requirements (another mark of
seniority and experience). "What's the most elegant and
efficient way to distinguish even numbers from odds without
using the notion of `two'?"

But first, define "even" and "odd" without using the notion of "two".
F(0) yields even. For n 0, F(n) yields odd iff F(n - 1) yields even.
Otherwise, it yields odd.

#define EVEN 0
#define ODD 1
int F(unsigned long n)
{
int result = EVEN;
if(n 0)
{
result = F(n - 1);
}
return result;
}
Then, define "prime" without using the notion of "division".
A prime is a positive integer greater than 1 that is not a multiple of any
other positive integer other than itself and 1.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 20 '07 #21
Richard Heathfield said:
Kenneth Brody said:
<snip>
>But first, define "even" and "odd" without using the notion of "two".

F(0) yields even. For n 0, F(n) yields odd iff F(n - 1) yields even.
Otherwise, it yields odd.

#define EVEN 0
#define ODD 1
int F(unsigned long n)
{
int result = EVEN;
if(n 0)
{
result = F(n - 1);
}
return result;
}
Stupid. Sorry. All numbers are even!

Let me try that again:

#define EVEN 0
#define ODD 1
int F(unsigned long n)
{
int result = EVEN;
if(n 0)
{
if(F(n - 1) == EVEN)
{
result = ODD;
}
else
{
result = EVEN;
}
}
return result;
}

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 20 '07 #22
On Sep 20, 10:03 am, Kenneth Brody <kenbr...@spamcop.netwrote:
Eric Sosman wrote:
Richard wrote:
[...]
And clearly he has an ulterior
motive for not wanting to use sizeof. I suspect home work for an
"impprovement" course.
Ayeh. One of the improvements should be the ability to
recognize and reject stupid requirements (another mark of
seniority and experience). "What's the most elegant and
efficient way to distinguish even numbers from odds without
using the notion of `two'?"
But first, define "even" and "odd" without using the notion of "two".
'Even' is when a value (converted to unsigned) is shifted right by 1
and then shifted left by 1 and remains unchanged.
Then, define "prime" without using the notion of "division".
Easy. Replace 'division' with 'repeated subtraction that yields 0
before going negative'.
Sep 20 '07 #23
In article <11**********************@d55g2000hsg.googlegroups .com>,
user923005 <dc*****@connx.comwrote:
>But first, define "even" and "odd" without using the notion of "two".
>'Even' is when a value (converted to unsigned) is shifted right by 1
and then shifted left by 1 and remains unchanged.
This assumes the notion of shifting which is usually explained with
reference to base TWO, so I think you still have some work left.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Sep 20 '07 #24
On Sep 20, 1:00 pm, rich...@cogsci.ed.ac.uk (Richard Tobin) wrote:
In article <1190316948.616200.213...@d55g2000hsg.googlegroups .com>,

user923005 <dcor...@connx.comwrote:
But first, define "even" and "odd" without using the notion of "two".
'Even' is when a value (converted to unsigned) is shifted right by 1
and then shifted left by 1 and remains unchanged.

This assumes the notion of shifting which is usually explained with
reference to base TWO, so I think you still have some work left.
The C language may have used the notion of 2 in implementation of the
semantics of unsigned shifts, but I didn't.

Sep 20 '07 #25
"Kenneth Brody" <ke******@spamcop.neta crit dans le message de news:
46***************@spamcop.net...
Eric Sosman wrote:
>>
Jeff P. Syverson wrote:
Can anyone tell me the best way to find out the size of a struct,
without
using the sizeof function? [...]

Of course, the question "how do I get the size of something without
using the made-for-this sizeof operator" is along the same lines as
"how do I get the weight of something without using a scale". Sure,
it can be done, but why?
I suspect the OP wants to avoid the overhead of what he assumes to be a
function call. The answer is simple: for the purpose of computing the size
of a structure, sizeof is an operator evaluated at compile time.

Writing size=sizeof(struct foo); is exactly as efficient as writing size=16;

As a matter of fact, his proposal size=(char*)&foo_array[1]-(char*)&foo[0]
may well generate the same code, or something more complicated with a
subtraction and 2 relocations, to ultimately produce the same result.

--
Chqrlie.
Sep 20 '07 #26
Kenneth Brody wrote:
>
.... snip ...
>
But first, define "even" and "odd" without using the notion of
"two". Then, define "prime" without using the notion of "division".
A number that cannot be duplicated by any multiple of any smaller
number greater or equal to two. But division is more efficient.
:-)

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Sep 20 '07 #27
In article <46***********************@news.free.fr>,
Charlie Gordon <ne**@chqrlie.orgwrote:
>I suspect the OP wants to avoid the overhead of what he assumes to be a
function call.
Given that the OP posted through a public news server with a
disclaimer referring to a company not (as far as I can see) mentioned
anywhere else on the Internet, my guess is that he is a troll.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Sep 20 '07 #28
In article <fc**********@pc-news.cogsci.ed.ac.uk>, I wrote:
>Given that the OP posted through a public news server with a
disclaimer referring to a company not (as far as I can see) mentioned
anywhere else on the Internet, my guess is that he is a troll.
A bit more searching reveals that a company with that name does exist,
and is an Indian outsourcing company. So I revise my guess to be that
he's doing that same Indian C course which has led so many other
people to ask the same question here recently.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Sep 20 '07 #29
Richard Tobin said:
In article <fc**********@pc-news.cogsci.ed.ac.uk>, I wrote:
>>Given that the OP posted through a public news server with a
disclaimer referring to a company not (as far as I can see) mentioned
anywhere else on the Internet, my guess is that he is a troll.

A bit more searching reveals that a company with that name does exist,
and is an Indian outsourcing company. So I revise my guess to be that
he's doing that same Indian C course which has led so many other
people to ask the same question here recently.
I wonder whether it's possible to killfile an entire sub-continent.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 20 '07 #30
Richard Heathfield wrote:
I wonder whether it's possible to killfile an entire sub-continent.
You can kill file the whole world... much easier!
Sep 20 '07 #31
"Richard Tobin" <ri*****@cogsci.ed.ac.uka crit dans le message de news:
fc**********@pc-news.cogsci.ed.ac.uk...
In article <fc**********@pc-news.cogsci.ed.ac.uk>, I wrote:
>>Given that the OP posted through a public news server with a
disclaimer referring to a company not (as far as I can see) mentioned
anywhere else on the Internet, my guess is that he is a troll.

A bit more searching reveals that a company with that name does exist,
and is an Indian outsourcing company. So I revise my guess to be that
he's doing that same Indian C course which has led so many other
people to ask the same question here recently.
So it was a beg indian problem.

--
Chqrlie.
Sep 20 '07 #32
Charlie Gordon said:
"Richard Tobin" <ri*****@cogsci.ed.ac.uka crit dans le message de
news: fc**********@pc-news.cogsci.ed.ac.uk...
<snip>
>So I revise my guess to be that he's doing that same Indian C course
which has led so many other people to ask the same question here
recently.

So it was a beg indian problem.

You're not allowed to talk any more.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 20 '07 #33
Richard Heathfield wrote:
Richard Tobin said:
>In article <fc**********@pc-news.cogsci.ed.ac.uk>, I wrote:
>>Given that the OP posted through a public news server with a
disclaimer referring to a company not (as far as I can see) mentioned
anywhere else on the Internet, my guess is that he is a troll.
A bit more searching reveals that a company with that name does exist,
and is an Indian outsourcing company. So I revise my guess to be that
he's doing that same Indian C course which has led so many other
people to ask the same question here recently.

I wonder whether it's possible to killfile an entire sub-continent.
That would be stupid and unjust, and also unjust and stupid,
not to mention unjust. Oh, and stupid, too. Need I say more more?

--
Eric Sosman
es*****@ieee-dot-org.invalid
Sep 21 '07 #34
On Wed, 19 Sep 2007 22:18:45 -0400, Roberto Waltman
<us****@rwaltman.netwrote:
>Ian Collins <ia******@hotmail.comwrote:
>>Jeff P. Syverson wrote:
>>... without using the sizeof function? ...
...
>>Why, sizeof is there for a good reason
...
>> [And then the grand finale, 15 lines of legalese]

Surly you can trim all this nonsense?

To all those who find this unusual, consider yourselves lucky you were
not forced to do the same.
There are companies that require this type of statements on outgoing
email. That text may have been added automatically by his employer
email system, with or without Mr. Syverson's consent.
Oddly enough, the sender had enough control to replace his email
address with no****@nospam.com. Makes one wonder why he couldn't get
rid of the boiler plate also.
Remove del for email
Sep 21 '07 #35
Eric Sosman said:
Richard Heathfield wrote:
>Richard Tobin said:
>>In article <fc**********@pc-news.cogsci.ed.ac.uk>, I wrote:

Given that the OP posted through a public news server with a
disclaimer referring to a company not (as far as I can see) mentioned
anywhere else on the Internet, my guess is that he is a troll.
A bit more searching reveals that a company with that name does exist,
and is an Indian outsourcing company. So I revise my guess to be that
he's doing that same Indian C course which has led so many other
people to ask the same question here recently.

I wonder whether it's possible to killfile an entire sub-continent.

That would be stupid and unjust, and also unjust and stupid,
not to mention unjust. Oh, and stupid, too. Need I say more more?
But, my dear chap, you haven't answered the question. I didn't ask whether
it would be sensible or just. I merely asked whether it would be possible.
:-)

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 21 '07 #36
Richard Heathfield wrote:
Eric Sosman said:
>Richard Heathfield wrote:
>>[...]
I wonder whether it's possible to killfile an entire sub-continent.
That would be stupid and unjust, and also unjust and stupid,
not to mention unjust. Oh, and stupid, too. Need I say more more?

But, my dear chap, you haven't answered the question. I didn't ask whether
it would be sensible or just. I merely asked whether it would be possible.
:-)
An apt summary of the thread's original question ...

--
Eric Sosman
es*****@ieee-dot-org.invalid
Sep 21 '07 #37
Eric Sosman <es*****@ieee-dot-org.invalidwrites:
Richard wrote:
>A Senior Systems
Engineer doesn't have to know any C.

Twenty years ago, no. And twenty years from now, perhaps
not. But today, right now, a systems engineer ignorant of C --
even of the bare basics of C -- ought not to carry the label
"senior."
Is a "systems engineer" necessarily someone who works on software
systems? I would not make that assumption.
--
Ben Pfaff
http://benpfaff.org
Sep 21 '07 #38
Ben Pfaff wrote, On 21/09/07 05:09:
Eric Sosman <es*****@ieee-dot-org.invalidwrites:
>Richard wrote:
>>A Senior Systems
Engineer doesn't have to know any C.
Twenty years ago, no. And twenty years from now, perhaps
not. But today, right now, a systems engineer ignorant of C --
even of the bare basics of C -- ought not to carry the label
"senior."

Is a "systems engineer" necessarily someone who works on software
systems? I would not make that assumption.
Nor would I having worked with Systems Engineers where the SW was only a
small part and said engineers would ask the SW Engineers for input on
SW, HW Engineers for input on HW, experts on optics for...
--
Flash Gordon
Sep 21 '07 #39
On Thu, 20 Sep 2007 15:46:31 +0000, Richard Heathfield wrote:
Army1987 said:
>On Thu, 20 Sep 2007 03:12:41 +0000, Richard Heathfield wrote:
>>Eric Sosman said:
[snip] "What's the most elegant and
>>>efficient way to distinguish even numbers from odds without
using the notion of `two'?"
>> return n & 1;

How do you explain what & does without using the notion of 'two'?
:-)

Yields the result of performing a bitwise AND of all its operands.
What does 'bitwise' mean? :-)

Btw, "n is even if (-1)**n is +1, odd if it is -1".

--
Army1987 (Replace "NOSPAM" with "email")
If you're sending e-mail from a Windows machine, turn off Microsoft's
stupid “Smart Quotes” feature. This is so you'll avoid sprinkling garbage
characters through your mail. -- Eric S. Raymond and Rick Moen

Sep 21 '07 #40
On Thu, 20 Sep 2007 17:41:22 -0700, Barry Schwarz <sc******@doezl.net>
wrote:
>On Wed, 19 Sep 2007 22:18:45 -0400, Roberto Waltman
<us****@rwaltman.netwrote:
>>Ian Collins <ia******@hotmail.comwrote:
>>>Jeff P. Syverson wrote:
... without using the sizeof function? ...
...
>>>Why, sizeof is there for a good reason
...
>>> [And then the grand finale, 15 lines of legalese]

Surly you can trim all this nonsense?

To all those who find this unusual, consider yourselves lucky you were
not forced to do the same.
There are companies that require this type of statements on outgoing
email. That text may have been added automatically by his employer
email system, with or without Mr. Syverson's consent.

Oddly enough, the sender had enough control to replace his email
address with no****@nospam.com. Makes one wonder why he couldn't get
rid of the boiler plate also.
If it were real company-required boilerplate, it would be added
*after* he hit the send button, unlike the email address.

--
Al Balmer
Sun City, AZ
Sep 21 '07 #41
Army1987 said:
Richard Heathfield wrote:
>Army1987 said:
>>Richard Heathfield wrote:
Eric Sosman said:
"What's the most elegant and efficient way to distinguish
even numbers from odds without using the notion of `two'?"

return n & 1;

How do you explain what & does without using the notion of 'two'?
:-)

Yields the result of performing a bitwise AND of all its operands.
What does 'bitwise' mean? :-)
It means "wise in the ways of small pieces". This is my last reply in this
subthread.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 21 '07 #42
On Thu, 20 Sep 2007 13:03:03 -0400, Kenneth Brody wrote:
But first, define "even" and "odd" without using the notion of "two".

Then, define "prime" without using the notion of "division".
And then explain Goldbach's conjecture without using either notion.
But wait, hasn't Hofstadter already done that?
(Unless "the successor of the successor of b" uses the notion of
"two", but that was just a workaround because he couldn't use the
notion of "greater than".)
--
Army1987 (Replace "NOSPAM" with "email")
A hamburger is better than nothing.
Nothing is better than eternal happiness.
Therefore, a hamburger is better than eternal happiness.

Sep 22 '07 #43

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by mike79 | last post: by
7 posts views Thread by ANaiveProgrammer | last post: by
2 posts views Thread by Arne Styve | last post: by
3 posts views Thread by Dirk Reske | last post: by
6 posts views Thread by Christian Kandeler | last post: by
7 posts views Thread by sarathy | last post: by
3 posts views Thread by David Bear | last post: by
8 posts views Thread by cman | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.