Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > Re: Promotions ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 8 Topic 1076 of 1126
Post > Topic >>

Re: Promotions while delivering parameters

by Brian Inglis <Brian.Inglis@[EMAIL PROTECTED] > Apr 18, 2008 at 04:11 PM

On Wed, 16 Apr 2008 16:56:33 -0500 (CDT) in comp.lang.c.moderated,
Dag-Erling Sm=F8rgrav <des@[EMAIL PROTECTED]
> wrote:

>Magi Su <magisu@[EMAIL PROTECTED]
> writes:
>> I am a student learning Expert C Programming.
>> One interesting topic I have found is that, which the book told me=
,
>> when we use K&R style declaration and definition of functions:
>>
>> int kandr();
>> ....
>> int kandr(p1,p2)
>>  int p1; char p2;
>> {}
>>
>> the 'char' parameter p2 is promoted to 'int' while pu****ng into st=
ack;
>> however, when we use ANSI style:
>>
>> int ansi(int p1,char p2)
>> {}
>>
>> the parameter p2 is pushed as 'char'.
>
>The C standard says absolutely nothing about how function parameters=
 are
>stored on the stack.  In fact, it says nothing about a stack, period=
..
>The exact mechanism by which parameters are passed to functions is l=
eft
>to the implementation, and *will* vary from one processor architectu=
re
>to another, one operating system to another, and even (in extreme ca=
ses)
>one compiler to another.

Even on machines which sup****t a hardware stack, and are not register
starved (we know which architecture that is), registers are used as m=
uch
as possible, often even in unoptimized code.=20

>I would expect a lecturer or textbook in "Expert C Programming" to k=
now
>and teach this.

Pedagogical simplification for purposes of exposition.=20

>I suspect you're not getting your money's worth.
>
>Get a copy of the C standard and read up about the difference betwee=
n
>the language and the implementation, and about alignment and padding=
,
>which is the closest you'll get to the issue you're asking about.
>
>Here's one place you can get a cheap copy of the standard:
>
>http://www.amazon.co.uk/C-Standard-British-Standards-Institute/dp/04=
70845732
for some values of cheap: GBP23; .de EUR56; .ca CA$77; .com US$85.=
=20

Download an even cheaper and I believe updated PDF with TCs applied
(US$30):=20
http://webstore.ansi.org/RecordDetail.aspx?sku=3DINCITS%2fISO%2fIEC+9=
899-1999+(R2005)

--=20
Thanks. Take care, Brian Inglis =09Calgary, Alberta, Canada

Brian.Inglis@[EMAIL PROTECTED]
 =09(Brian[dot]Inglis{at}SystematicSW[dot]ab[dot]=
ca)
    fake address=09=09use address above to reply
-- 
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
 -- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
 




 8 Posts in Topic:
Promotions while delivering parameters
Magi Su <magisu@[EMAIL  2008-04-13 02:41:49 
Re: Promotions while delivering parameters
Francis Glassborow <fr  2008-04-16 16:56:02 
Re: Promotions while delivering parameters
=?utf-8?Q?Dag-Erling_Sm=C  2008-04-18 16:11:36 
Re: Promotions while delivering parameters
Francis Glassborow <fr  2008-04-21 13:20:21 
Re: Promotions while delivering parameters
=?utf-8?Q?Dag-Erling_Sm=C  2008-04-16 16:56:33 
Re: Promotions while delivering parameters
Brian Inglis <Brian.In  2008-04-18 16:11:55 
Re: Promotions while delivering parameters
Kenneth Brody <kenbrod  2008-04-16 16:56:45 
Re: Promotions while delivering parameters
=?utf-8?Q?Dag-Erling_Sm=C  2008-04-18 16:11:39 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 0:38:26 CDT 2008.