Keil Logo Arm Logo

sizeof operator

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
siva krishna
Posted
1-Sep-2009 10:38 GMT
Toolset
C51
New! sizeof operator

Hai can anyone give the information abt sizeof... how to sizeof operatot exactly in 8051 family

Read-Only
Author
Andrew Neil
Posted
1-Sep-2009 11:08 GMT
Toolset
None
New! Textbook time

There is nothing peculiar about sizeof in C51; it works as standard ANSI 'C' - therefore you should find the necessary information any 'C' textbook.

eg:

http://www.keil.com/books/

http://c-faq.com/

http://publications.gbdirect.co.uk/c_book/

Read-Only
Author
Jack Sprat
Posted
2-Sep-2009 14:00 GMT
Toolset
None
New! RE: Textbook time

There is nothing peculiar about sizeof in C51; it works as standard ANSI 'C'

There is an exception: In standard 'C' the result of sizeof is always a size_t, whereas in C51 the result may or may not be a size_t depending in its value.

It may not sound particularly important but can cause some surprises with variadic functions in particular.

Read-Only
Author
Andy Neil
Posted
2-Sep-2009 21:37 GMT
Toolset
C51
New! RE: in C51 the result may or may not be a size_t

Does that depend on whether the standard Integer Promotions are enabled or not...?

Read-Only
Author
Jack Sprat
Posted
3-Sep-2009 13:26 GMT
Toolset
C51
New! RE: in C51 the result may or may not be a size_t

Does that depend on whether the standard Integer Promotions are enabled or not...?

No, C51 always treats an integer constant as an 8 bit value if it will fit into one. The 'integer promotions' or whatever Keil calls them only apply to operator operands not to variadic function arguments. If I remember correctly the position with non-prototyped non-variadic functions is unimportant as the compiler simply won't accept them.

It's safest to always qualify constants at the point of definition and to cast constants when passing them to variadic functions unless you have a good reason not to do so.

The documentation of these issues is scant as best and I don't think they are mentioned in their published 'differences from ISO C', which is pretty poor show.

Read-Only
Author
Kalib Rahib
Posted
1-Sep-2009 11:08 GMT
Toolset
C51
New! RE: sizeof operator

you not be knowing the sizeof is C and the 8051 is not being anything special.

look at sizeof in your bookings with C or on teh internet web

here is the example

http://en.wikipedia.org/wiki/Sizeof

Read-Only
Author
Andy Neil
Posted
1-Sep-2009 13:37 GMT
Toolset
C51
New! RE: the 8051 is not ... anything special

Oh, some people think that the 8051 is very special...

;-)

Read-Only
Author
stephen phillips
Posted
1-Sep-2009 13:47 GMT
Toolset
C51
New! RE: the 8051 is not ... anything special

At least it isn't unique in it's 'special'ness.

Stephen

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

ARM’s Privacy Policy has been updated. By continuing to use our site, you consent to ARM’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.