comp.lang.c - 26 new messages in 7 topics - digest
comp.lang.c
http://groups.google.com/group/comp.lang.c?hl=en
Today's topics:
* Difference between Cygwin and DOS handling of string input - 6 messages, 5
authors
http://groups.google.com/group/comp.lang.c/t/bff908501014be74?hl=en
* "riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen wallpapers"
"riya sen blue film" "riya sen hot" "riya sen pics" "riya sen" "riya sen
ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/ - 1
messages, 1 author
http://groups.google.com/group/comp.lang.c/t/f99b81c8e7b33547?hl=en
* Pointer to inside an array - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/227c21b5449d807c?hl=en
* Defining an alias - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/76cfbae69d7b12b0?hl=en
* Wrapping in unsigned char - 12 messages, 5 authors
http://groups.google.com/group/comp.lang.c/t/737d09dd2f21a005?hl=en
* A question about passing values to a function. - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/8558615c4752c07e?hl=en
* Direct support for various Statistical functions - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/8a248ddeff7b1cfc?hl=en
==============================================================================
TOPIC: Difference between Cygwin and DOS handling of string input
http://groups.google.com/group/comp.lang.c/t/bff908501014be74?hl=en
==============================================================================
== 1 of 6 ==
Date: Sat, Dec 19 2009 12:03 am
From: Michael Foukarakis
On Dec 18, 2:58 pm, Tom St Denis <t...@iahu.ca> wrote:
> On Dec 18, 4:55 am, Michael Foukarakis <electricde...@gmail.com>
> wrote:
>
> > On Dec 17, 8:23 pm, Tom St Denis <t...@iahu.ca> wrote:> Also I don't consider Windows "modern." I consider them way behind
> > > the times.
>
> > There's a word for that. 'Denial'.
>
> I guess we have different criteria for advanced or modern. To me if I
> BUY and install a distro [of whatever] then have to buy/find/scrounge
> around for tools to actually make it useful, while many other distros
> make that available by default... it's not an advanced OS.
>
> I mean let's work down the list of things you don't get from a blank
> Vista/Win7 install
>
> - compiler, build tools like make, cvs/rcs, debuggers, etc...
> - real shell [that is compatible with the 1000s upon 1000s of scripts
> out there]
> - remote shell access [rdesktop is cool but let's be real, TTY is
> often better]
> - Office Suite
> - Image Editing Tools
> - Audio Mixing Tools
> - Tux Racer
> - Ton of userland tools that make work possible (perl, sed, awk, grep,
> find, xargs, gzip, ...)
> - oh, and the source to all of that
>
> > Powershell. And cmd *is* a shell.
>
> cmd.exe is a shell in that it's a TTY that lets you run commands, but
> compared to the versatility of say bash ... get real.
>
> And Powershell is not remotely compatible with sh/csh/tcsh/bash. It
> uses it's own scripting language because it's "special."
>
> > > They still don't come with useful userland
> > > tools,
>
> > Please point me to the Linux/UNIX analogous of OllyDbg. Then you can
> > talk shit again.
>
> Well show me in Win7 where you get tools like sed, perl, awk,
> grep, ...
>
> And before you comment on the usefulness, a very common one I get is
> say you have a directory of 100s of files with the names like
>
> Family_Summer_2007_*.jpg
>
> And you want to change it to 2008. How do you do that in Powershell
> or cmd.exe?
>
I'm just going to redirect you to Command Line Kung Fu, an excellent
source of associated tricks. You have lots to learn, I suggest you
start fast.
After that, I also suggest you study the separation between an
operating system and user application.
Have fun.
== 2 of 6 ==
Date: Sat, Dec 19 2009 1:52 am
From: Nick <3-nospam@temporary-address.org.uk>
Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
> Nick <3-nospam@temporary-address.org.uk> writes:
>
>> Flash Gordon <smap@spam.causeway.com> writes:
>>
>>> Oh, and an advantage of \r\n as your line termination is that it
>>> matches most of the text based internet protocols.
>>
>> Can someone remind me exactly of how this works. AIUI (and could be
>> wrong), '\n' will be translated to whatever is appropriate for the
>> system.
>
> On output to a text file, yes, but binary mode is best for handling a
> protocol stream.
>
>> So could generate a CR LF pair on DOS and its descendents, LF on
>> Unix and something else entirely on something else (like start next
>> record on IBMs with fixed length records).
>>
>> If I want to send the necessary characters for an Internet header,
>> irrespective of what OS my code will be running on (well, as far as Unix
>> and Windows goes anyway) what should I write? Is there a risk that "\r\n"
>> will generate two CRs?
>
> Not on a binary stream. The best way to ensure you get what you write
> (or that you read what is really there) is to use binary mode for such
> streams.
So how to I, portably, convert stdout to "binary mode"?
--
Online waterways route planner: http://canalplan.org.uk
development version: http://canalplan.eu
== 3 of 6 ==
Date: Sat, Dec 19 2009 5:17 am
From: Gareth Owen
Tom St Denis <tom@iahu.ca> writes:
> Well show me in Win7 where you get tools like sed, perl, awk, grep,
> ...
You get them from www.mingw.org
Look for the msys environment.
> And before you comment on the usefulness, a very common one I get is
> say you have a directory of 100s of files with the names like
>
> Family_Summer_2007_*.jpg
>
> And you want to change it to 2008. How do you do that in Powershell
> or cmd.exe?
In cmd.exe you type "bash".
Then when the bash executable has started, you type
for i in Family_Summer_2007_*.jpg
do mv -i "$i" "${i/_2007_/_2008_}"
done
Command shells are not the same things as operating systems.
Operating systems are not same thing as command shells.
Gareth Owen -- exclusively Linux at home since the mid-90s, happily
using Windows XP with mingw/msys at work.
== 4 of 6 ==
Date: Sat, Dec 19 2009 6:02 am
From: Ben Bacarisse
Nick <3-nospam@temporary-address.org.uk> writes:
> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>
>> Nick <3-nospam@temporary-address.org.uk> writes:
>>
>>> Flash Gordon <smap@spam.causeway.com> writes:
>>>
>>>> Oh, and an advantage of \r\n as your line termination is that it
>>>> matches most of the text based internet protocols.
>>>
>>> Can someone remind me exactly of how this works. AIUI (and could be
>>> wrong), '\n' will be translated to whatever is appropriate for the
>>> system.
>>
>> On output to a text file, yes, but binary mode is best for handling a
>> protocol stream.
<snip>
> So how to I, portably, convert stdout to "binary mode"?
You can't. You can try, of course, with freopen but that can fail to
have the desired effect.
I hope you did not think I was saying that it's all easy and there is
no problem. I was just saying that a binary stream is the only
portable way go, despite the ensuing restrictions such as not being
able to use stdout for this purpose.
--
Ben.
== 5 of 6 ==
Date: Sat, Dec 19 2009 6:42 am
From: Richard
Richard Heathfield <rjh@see.sig.invalid> writes:
> In
> <fbd600c5-ad0a-4b3d-919a-6c1007a93941@q16g2000vbc.googlegroups.com>,
> Tom St Denis wrote:
>
>> On Dec 18, 1:04 pm, Richard <rgrd...@gmail.com> wrote:
>>> Flash Gordon <s...@spam.causeway.com> writes:
>
> <snip>
>
>>> > Now please, everyone, stop
>>> > arguing about which OSs are real/advanced/crap or whatever. You
>>> > all know that has sod all to do with even the widest possible
>>> > definition of the purpose of this group.
>>>
>>> Wrong of course since the OS might determine the C tools in use.
>>> And C and its uses are most definitely ARE on topic here.
>>
>> Actually that's wrong anyways
Wrong. Or are you really trying to tell me that the OS has no impact on
the tools used? As someone who was unaware of chunk handling in modern
RCS systems I suspect your views on the tools might be a tad
limited. Your recent anti MS rants suggest you are a bit blinkered.
>
> That goes without saying. You're arguing with someone who contributes
> nothing but bile to the group, and whose views on topicality are of
> little more than passing interest to even the most relaxed of
> readers. Why bother?
>
> <snip>
Bile? Calling you a conceited arse is not bile. If you didn't hide
behind killfiles you would realise that.
--
"Avoid hyperbole at all costs, its the most destructive argument on
the planet" - Mark McIntyre in comp.lang.c
== 6 of 6 ==
Date: Sat, Dec 19 2009 6:43 am
From: Richard
Flash Gordon <smap@spam.causeway.com> writes:
> Richard wrote:
>> Flash Gordon <smap@spam.causeway.com> writes:
>>
>>> Kenny McCormack wrote:
>>>> In article <6339bd6a-0354-40bf-ab73-72df047caa4d@1g2000vbe.googlegroups.com>,
>>>> Tom St Denis <tom@iahu.ca> wrote:
>>>>> On Dec 18, 10:11 am, Richard <rgrd...@gmail.com> wrote:
>>> <snip>
>>>
>>>> P.S. Where, or where, are the regs telling us this advocacy stuff is
>>>> really, really, off-topic? Where is a reg when you need one???
>>> I've already made that request once. Now please, everyone, stop arguing
>>> about which OSs are real/advanced/crap or whatever. You all know that
>>> has sod all to do with even the widest possible definition of the
>>> purpose of this group.
>>
>> Wrong of course since the OS might determine the C tools in use. And C
>> and its uses are most definitely ARE on topic here.
>
> The state of your bank balance might determine the C tools in use, since
> you might not be able to afford to buy a commercial C compiler, so do
> you want to post your last bank statement here for review?
What are you talking about? That is one the most ridiculous things even
you have posted.
--
"Avoid hyperbole at all costs, its the most destructive argument on
the planet" - Mark McIntyre in comp.lang.c
==============================================================================
TOPIC: "riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya sen" "
riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.
com/
http://groups.google.com/group/comp.lang.c/t/f99b81c8e7b33547?hl=en
==============================================================================
== 1 of 1 ==
Date: Sat, Dec 19 2009 12:49 am
From: Naeem
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
"riya sen" "riya sen ashmit patel mms" "riya sen mms" "riya sen
wallpapers" "riya sen blue film" "riya sen hot" "riya sen pics" "riya
sen" "riya sen ashmit patel mms" "riya sen mms" on http://desi-girls-club.blogspot.com/
==============================================================================
TOPIC: Pointer to inside an array
http://groups.google.com/group/comp.lang.c/t/227c21b5449d807c?hl=en
==============================================================================
== 1 of 3 ==
Date: Sat, Dec 19 2009 12:58 am
From: Barry Schwarz
On Thu, 17 Dec 2009 19:45:28 -0800 (PST), Peter Nilsson
<airia@acay.com.au> wrote:
>Barry Schwarz <schwa...@dqel.com> wrote:
>> Alok Singhal
>> > Please bear with me while I try to explain myself. Isn't
>> > there a difference between:
>> >
>> > int array[5] = {2};
>> > int (*ptr)[5] = &array;
>> >
>> > and:
>> >
>> > int array[20] = {2};
>> > int (*ptr)[5] = (int (*)[5])(array + 6);
>>
>> ...the question revolves around whether a+6 is properly aligned.
>>
>> Consider the definition
>> int x[sizeof(int)][5];
>
>I have no idea why you think sizeof(int) should be used here!
I thought it would insure exhaustion but, as you point out below, it
works only for currently common implementations and fails in the
perverse case.
>
>> We know that each element x[i][j] occupies exactly sizeof(int)
>> bytes. Further more, each element x[i][j+1] starts exactly
>> sizeof(int) bytes beyond the start of the previous element
>> x[i][j] (except for the obvious boundary condition when j==4).
>>
>> We also know that each x[i] is an array of 5 int and that
>> x[i+1] starts exactly 5*sizeof(int) bytes beyond the start
>> of x[i] (again except for the boundary condition when i==
>> sizeof(int)-1).
>>
>> Because sizeof(int) is not a factor of 5,
>
>Not commonly, but on the virtual machine it may be.
>
>> I assert the x[i] as a group completely exhaust all possible
>> alignments for int[5] and that they also completely exhaust
>> all possible alignments for int. ...
>
>I've had a previous discussion considering something like...
>
> int a[7];
> int (*p)[2] = (int (*)[2]) (a + 1);
>
>The problem is whether int(*)[2] can have a stricter
>alignement than int *. I think it can! I can't see anything
>in the standard that says a pointer to an element of an array
>of N elements will always be properly aligned for a pointer
>to an array of M elements if M < N.
Yes. If the dimension of the array pointed to is a factor of
sizeof(int), then my argument fails. For example, if sizeof(int) is 4
and the alignment for int[2] is 8, then obviously a+1 or a+2 must be
misaligned for p.
Applying this to the specific example under consideration where the
dimension is 5, this can happen only if the alignment for an int[5] is
a multiple of 5*sizeof(int), such as 20 to match the example. In such
a case, array+6 may or may not be properly aligned but if it is then
array+7 is definitely not.
So to the OP I apologize for the error in my response. It is probably
properly aligned on all current systems you are likely to run on but
it may very well invoke undefined behavior on the DS9K or some new
system where the alignment of int[5] is more restrictive than that of
int.
>
>Why should it? Look at an example using structs...
>
> struct int_pair_t { int a; int b; };
> int a[7];
> struct int_pair_t *p = (struct int_pair_t *) (a + 1);
>
>Even if one shows that there is no padding in the struct,
>there is still no guarantee that a + 1 is properly aligned
>for a struct int_pair_t *.
>
>Simple question: Is there anything precluding an
>implementation giving struct int_pair_t a stricter
>alignment than int?
>
>[This is ignoring the issue of effective type which plays
>a further role in the discussion.]
--
Remove del for email
== 2 of 3 ==
Date: Sat, Dec 19 2009 9:22 am
From: Alok Singhal
On Dec 17, 7:02 pm, Barry Schwarz <schwa...@dqel.com> wrote:
>
> So the question revolves around whether a+6 is properly aligned.
Yes, I think I wasn't clear enough in my posts so far. This indeed
was my question to begin with.
> Consider the definition
> int x[sizeof(int)][5];
>
> We know that each element x[i][j] occupies exactly sizeof(int) bytes.
> Further more, each element x[i][j+1] starts exactly sizeof(int) bytes
> beyond the start of the previous element x[i][j] (except for the
> obvious boundary condition when j==4).
>
> We also know that each x[i] is an array of 5 int and that x[i+1]
> starts exactly 5*sizeof(int) bytes beyond the start of x[i] (again
> except for the boundary condition when i==sizeof(int)-1).
>
> Because sizeof(int) is not a factor of 5, I assert the x[i] as a group
> completely exhaust all possible alignments for int[5] and that they
> also completely exhaust all possible alignments for int. (I don't
> remember what the branch of mathematics is called that is used to
> prove these assertions but if you choose both common (2, 4, and 8) and
> off-the-wall (3, 15 23) values for sizeof(int) and work out the
> addresses you should be convinced.) Consequently, the value a+6 will
> exactly match the alignment of at least one of the x[i] and is
> therefore properly aligned.
OK. I see. I can agree with your arguments. But sizeof(int) can be a
factor of 5 theoretically, and the number 5 in my original post is
something I picked out of convenience. In general, it could be any
number (2, 8, 4, whatever). Similarly, the same goes for the numbers
and 6, and 20 in my original post. So, given
int a[N] = {0};
int (*p)[m] = (int (*)[m])(a+k);
with N, m, k as integers (and k+m < N of course), I can't be sure if a
+k is properly aligned for int (*)[m]?
Thanks a lot for your responses!
-Alok
== 3 of 3 ==
Date: Sat, Dec 19 2009 9:25 am
From: Alok Singhal
On Dec 19, 12:58 am, Barry Schwarz <schwa...@dqel.com> wrote:
> On Thu, 17 Dec 2009 19:45:28 -0800 (PST), Peter Nilsson
>
> So to the OP I apologize for the error in my response. It is probably
> properly aligned on all current systems you are likely to run on but
> it may very well invoke undefined behavior on the DS9K or some new
> system where the alignment of int[5] is more restrictive than that of
> int.
No need for the apology - I learned quite a lot from your and Peter's
answers, and I should have been more specific to begin with. After
all these years of lurking here in clc, I thought I was ready to post
an interesting question (interesting to me anyway). :-)
-Alok
==============================================================================
TOPIC: Defining an alias
http://groups.google.com/group/comp.lang.c/t/76cfbae69d7b12b0?hl=en
==============================================================================
== 1 of 2 ==
Date: Sat, Dec 19 2009 1:46 am
From: jacob navia
jacob navia a écrit :
(snip)
Thanks for the answers guys. Yes, the "static inline" syntax is better.
I think that the container library will require C99 then, and leave
Microsoft compilers out... They have inline, but I do not remember if
they accept it in C mode.
jacob
== 2 of 2 ==
Date: Sat, Dec 19 2009 8:43 am
From: Keith Thompson
jacob navia <jacob@spamsink.net> writes:
> jacob navia a écrit :
> (snip)
>
> Thanks for the answers guys. Yes, the "static inline" syntax is better.
>
> I think that the container library will require C99 then, and leave
> Microsoft compilers out... They have inline, but I do not remember if
> they accept it in C mode.
What's wrong with the const function pointer solution?
--
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"
==============================================================================
TOPIC: Wrapping in unsigned char
http://groups.google.com/group/comp.lang.c/t/737d09dd2f21a005?hl=en
==============================================================================
== 1 of 12 ==
Date: Sat, Dec 19 2009 2:08 am
From: happy
#include<stdio.h>
int main()
{
unsigned char i=255,j=1;
printf("%d\n",i+j);
}
The output of above code is 256.
Why is there no wrapping ?
== 2 of 12 ==
Date: Sat, Dec 19 2009 2:14 am
From: Ian Collins
happy wrote:
> #include<stdio.h>
>
> int main()
> {
> unsigned char i=255,j=1;
>
> printf("%d\n",i+j);
>
> }
> The output of above code is 256.
> Why is there no wrapping ?
Because the argument to printf is promoted to int. That's what happens
to unsigned char when passed to a variadic function.
Compare this with:
#include<stdio.h>
void f( unsigned char i )
{
printf("%d\n",i);
}
int main()
{
unsigned char i=255,j=1;
f(i+j);
}
Where there isn't any promotion.
--
Ian Collins
== 3 of 12 ==
Date: Sat, Dec 19 2009 3:03 am
From: happy
On Dec 19, 3:14 pm, Ian Collins <ian-n...@hotmail.com> wrote:
> happy wrote:
> > #include<stdio.h>
>
> > int main()
> > {
> > unsigned char i=255,j=1;
>
> > printf("%d\n",i+j);
>
> > }
> > The output of above code is 256.
> > Why is there no wrapping ?
>
> Because the argument to printf is promoted to int. That's what happens
> to unsigned char when passed to a variadic function.
>
> Compare this with:
>
> #include<stdio.h>
>
> void f( unsigned char i )
> {
> printf("%d\n",i);
>
> }
>
> int main()
> {
> unsigned char i=255,j=1;
>
> f(i+j);
>
> }
>
> Where there isn't any promotion.
>
> --
> Ian Collins
Thanks Collins.
But I am really confused about when and how to apply these promotions
and conversions.
I mean how to know where we have to apply certain conversions?
== 4 of 12 ==
Date: Sat, Dec 19 2009 4:23 am
From: "Johannes Schaub (litb)"
happy wrote:
> #include<stdio.h>
>
> int main()
> {
> unsigned char i=255,j=1;
>
> printf("%d\n",i+j);
>
> }
> The output of above code is 256.
> Why is there no wrapping ?
There is a promotion *prior* to adding i and j. Both are either promoted to
int or unsigned int, depending on whether on your implementation "int" can
store all possible values of "unsigned char" (called "usual arithmetical
conversions). If that's the case, both operands become "int", and then are
added together, and the result is guaranteed not to overflow (because
INT_MAX is at least 2^15-1).
This does not have to do with promotion of arguments to printf, since if it
would wrap around during addition and then promoted (called "default
argument promotions"), we would pass 0 instead of 256.
== 5 of 12 ==
Date: Sat, Dec 19 2009 4:28 am
From: ram@zedat.fu-berlin.de (Stefan Ram)
Ian Collins <ian-news@hotmail.com> writes:
>>printf("%d\n",i+j);
>Because the argument to printf is promoted to int.
This can not be the real reason, because this conversion
only happens after the sum was already calculated.
The point is that the type of the sum - even outside
of printf - is larger than unsigned char, at least
for the C implementation I used to run this program:
#include <stdio.h>
int main( void )
{ unsigned char const i = 255;
unsigned char const j = 1;
int const is = sizeof i;
int const ijs = sizeof( i + j );
printf( "%d\n", is );
printf( "%d\n", ijs ); }
/* prints
1
4
*/
But where in ISO/IEC 9899:1999 (E) is the type of
"i + j" specified?
== 6 of 12 ==
Date: Sat, Dec 19 2009 4:31 am
From: ram@zedat.fu-berlin.de (Stefan Ram)
ram@zedat.fu-berlin.de (Stefan Ram) writes:
>But where in ISO/IEC 9899:1999 (E) is the type of
>"i + j" specified?
Oh, now I see:
It seems to be this sentence:
»the integer promotions are performed on both operands.«
in 6.3.1.8#1 of ISO/IEC 9899:1999 (E).
== 7 of 12 ==
Date: Sat, Dec 19 2009 5:03 am
From: happy
On Dec 19, 5:31 pm, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
> r...@zedat.fu-berlin.de (Stefan Ram) writes:
> >But where in ISO/IEC 9899:1999 (E) is the type of
> >"i + j" specified?
>
> Oh, now I see:
>
> It seems to be this sentence:
>
> »the integer promotions are performed on both operands.«
>
> in 6.3.1.8#1 of ISO/IEC 9899:1999 (E).
I still couldn't get the answer of my second question.
Is there any article which specifies all conditions for promotions and
conversions.
== 8 of 12 ==
Date: Sat, Dec 19 2009 5:12 am
From: "Johannes Schaub (litb)"
happy wrote:
> On Dec 19, 5:31 pm, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
>> r...@zedat.fu-berlin.de (Stefan Ram) writes:
>> >But where in ISO/IEC 9899:1999 (E) is the type of
>> >"i + j" specified?
>>
>> Oh, now I see:
>>
>> It seems to be this sentence:
>>
>> »the integer promotions are performed on both operands.«
>>
>> in 6.3.1.8#1 of ISO/IEC 9899:1999 (E).
>
> I still couldn't get the answer of my second question.
> Is there any article which specifies all conditions for promotions and
> conversions.
You would have to read the Standard if you wanna know for sure. It's not
that difficult to read.
== 9 of 12 ==
Date: Sat, Dec 19 2009 5:17 am
From: happy
On Dec 19, 6:12 pm, "Johannes Schaub (litb)" <schaub-johan...@web.de>
wrote:
> happy wrote:
> > On Dec 19, 5:31 pm, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
> >> r...@zedat.fu-berlin.de (Stefan Ram) writes:
> >> >But where in ISO/IEC 9899:1999 (E) is the type of
> >> >"i + j" specified?
>
> >> Oh, now I see:
>
> >> It seems to be this sentence:
>
> >> »the integer promotions are performed on both operands.«
>
> >> in 6.3.1.8#1 of ISO/IEC 9899:1999 (E).
>
> > I still couldn't get the answer of my second question.
> > Is there any article which specifies all conditions for promotions and
> > conversions.
>
> You would have to read the Standard if you wanna know for sure. It's not
> that difficult to read.- Hide quoted text -
>
> - Show quoted text -
But In standard, it's all scattered.
== 10 of 12 ==
Date: Sat, Dec 19 2009 5:23 am
From: ram@zedat.fu-berlin.de (Stefan Ram)
happy <hppymittal@yahoo.com> writes:
>Is there any article which specifies all conditions for
>promotions and conversions.
This is supposed to be ISO/IEC 9899:1999 (E).
»Question 11.2 - How can I get a copy of the Standard? «
http://www.eskimo.com/~scs/c-faq.com/ansi/avail.html
== 11 of 12 ==
Date: Sat, Dec 19 2009 6:46 am
From: ram@zedat.fu-berlin.de (Stefan Ram)
happy <hppymittal@yahoo.com> writes:
>But In standard, it's all scattered.
One could create an excerpt containing only those parts that
pertain to integer arithmetic, but publishing such an
excerpt might constitute a copyright infringement.
This might be a reason, why nobody has done this so far.
== 12 of 12 ==
Date: Sat, Dec 19 2009 7:28 am
From: Eric Sosman
On 12/19/2009 8:17 AM, happy wrote:
> On Dec 19, 6:12 pm, "Johannes Schaub (litb)"<schaub-johan...@web.de>
> wrote:
>> happy wrote:
>>> On Dec 19, 5:31 pm, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
>>>> r...@zedat.fu-berlin.de (Stefan Ram) writes:
>>>>> But where in ISO/IEC 9899:1999 (E) is the type of
>>>>> "i + j" specified?
>>
>>>> Oh, now I see:
>>
>>>> It seems to be this sentence:
>>
>>>> »the integer promotions are performed on both operands.«
>>
>>>> in 6.3.1.8#1 of ISO/IEC 9899:1999 (E).
>>
>>> I still couldn't get the answer of my second question.
>>> Is there any article which specifies all conditions for promotions and
>>> conversions.
>>
>> You would have to read the Standard if you wanna know for sure. It's not
>> that difficult to read.
>
> But In standard, it's all scattered.
For the case in point, you'd look up the description of the
additive operators, and you'd find (in 6.5.6) "If both operands
have arithmetic type, the usual arithmetic conversions are performed
on them." Other operators are described similarly -- but often not
identically, since the rules for different operators are not all
exactly alike. For example, some operators apply the more limited
"integer promotions" instead of the full-blown "usual arithmetic
conversions."
6.3 describes the various kinds of conversions in one place,
so the rest of the Standard can just refer to them by name. It
seems to me a logical arrangement -- certainly clearer than
trying to write a section describing "All The Circumstances That
Cause Conversions." In the current arrangement, for example,
you can read about calls to variable-argument functions and learn
that the "..." arguments obey different conversion rules than the
fixed arguments. In an "All Conversions In One Place" arrangement,
the description of the function call would say "These are the
arguments" and the fact that some are converted differently than
others would be in a section fifty pages away.
--
Eric Sosman
esosman@ieee-dot-org.invalid
==============================================================================
TOPIC: A question about passing values to a function.
http://groups.google.com/group/comp.lang.c/t/8558615c4752c07e?hl=en
==============================================================================
== 1 of 1 ==
Date: Sat, Dec 19 2009 9:21 am
From: "Malcolm McLean"
"Chad" <cdalten@gmail.com> wrote in message
>
>I was wondering if it is possible to pass type int (as opposed to its
>value) when I call foo(). Could I do this using pointers in C?
>
Not really. You can pass a void pointer followed by some sort of symbol to
tell the function foo() how to interpret the void *.
foo(void *ptr, char *type)
{
int xint;
float xfloat;
if(!strcmp(type, "int"))
xint = *(int *) ptr;
else if(!strcmp(type, "float"))
xfloat = *(float *) ptr;
}
However there's rarely much point doing this. An exception is the printf()
family of functions, which use a related mechanism. (The format string is
used to pull the other arguments off a variable-length argument stack).
==============================================================================
TOPIC: Direct support for various Statistical functions
http://groups.google.com/group/comp.lang.c/t/8a248ddeff7b1cfc?hl=en
==============================================================================
== 1 of 1 ==
Date: Sat, Dec 19 2009 9:25 am
From: "Malcolm McLean"
"Michael Angelo Ravera" <maravera@prodigy.net> wrote in message news:
> I'm working mostly in Visual Studio, but other libraries or code
> snippets are welcome. It would nice just to call the function
> NormalDist or whatever.
>
> Where can I find good, fast approximations to such Statistical
> functions as are commonly found in spreadsheets. I am mostly
> interested in rounding points for integer or rational approximations,
> but the floating point equivalents will do well.
>
Unless your circumstances are very unusual almost any C implementation will
be fast enough for statistical work.
If you want an industrial strength package ypu can plug in, see Dann's post.
If you want to see how to implement such functions yourself, try Numerical
Recipies. I've also got some simple statistical routines in Basic Algorithms
(http://www.personal.leeds.ac.uk/~bgy1mm)
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.c"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.c?hl=en
To unsubscribe from this group, send email to comp.lang.c+unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home