define uint8_t

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi

can anyone tell me why would someone use the uint8_t function in their program

thanks

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Same as unsigned char..... if its just a boolean or a small integer, signed and unsigned generate about the same code, but in a loop testing a signed int for twos complement >= <= conditions sometimes takes two instructions... test the equal to zero bit, test the overflow bit.... so unsigned char is good for lean and mean code when you know it never goes negative....

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also, uint8_t is fairly standard across platforms. When you use that define, you are guaranteed that it is an 8-bit unsigned type.

You can also ask this on the GCC forum (where you're more likely to encounter it).

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bob's right, and of course it's a *lot* quicker typing uint8_t (and uint16_t, etc) than "unsigned char" (or "unsigned short", etc). :)

The C language doesn't say too much about the actual size of the data types (within certain constraints), it's left to the compiler writer to choose the best size for his/her particular target.

When writing microcontroller code we so often care very much about the true size of the variables (for bit-manipulating, etc) so in many ways these typedefs are preferable.

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Removed spam.

Last Edited: Thu. Oct 29, 2015 - 06:52 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I think you win the prise for thread necromancy.  A thread so old, none of the the member accounts which started it or contributed to it exist any more, and the posts have been assigned to the 'admin' place-holder account.

 

Eleven years, ten months, and thirteen days. Four thousand, three hundred, and thirty-five days.

 

Yup.  Definitely a winner!

 

EDIT: and now I see it's just one of 5 recent SPAM posts!!!

https://www.avrfreaks.net/comment/1699091#comment-1699091

I would stop

/EDIT

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Thu. Oct 29, 2015 - 05:32 AM