Where are the data types (newbie)

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

Sorry I am not a programmer but doing the best I can to get by. My main concern is understanding "uint8_t" but I would like to find a list of all data types for ATtiny. I am programming with gnugcc and AVR Studio. Shouldn't this be in the avr-libc Reference Manual? If not, what documentation should I be looking for? Thanks.

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

jwriter wrote:
Sorry I am not a programmer but doing the best I can to get by. My main concern is understanding "uint8_t" but I would like to find a list of all data types for ATtiny. I am programming with gnugcc and AVR Studio. Shouldn't this be in the avr-libc Reference Manual? If not, what documentation should I be looking for? Thanks.

Data types are not ATtiny specific. They are compiler specific, and are listed in C books and standards.

uint8_t and the like are belong to a certain C standard and they are defined in stdint.h file, so just #include that and take a look at what types it provides.

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

Quote:

Shouldn't this be in the avr-libc Reference Manual?

It is?!?

http://www.nongnu.org/avr-libc/u...

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

Update: I found the page "C data types" in Wikipedia but there is no clear explanation of what the "_t" means. I think it is true/false boolean. If so, does that mean that logical operations can be performed on the data? What happens if you perform logical operations on "uint8" data?

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

_t is short for "type". For many moons C has had things like size_t so when the standards committee proposed stdint.h it was natural to suggest the new type names have the same _t suffix to identify them as being typedef's.

The C standard is very clear what happens when you use integer variables and constants where a logical type is expected. For example:

if (13) {
  PORTB = 0x15;
}

which is the same as:

uint8_t n = 13;
if (n) {
  PORTB = 0x15;
}

is unequivocal. The non-zero value (13) will be interpreted as "true" so the PORTB assignment will always be made. Similarly:

uint8_t n = 0;
if (n) {
  PORTB = 0x15;
}

absolutely guarantees that the assignment is not made as zero is the one integer value interpreted as "false".

If you want to convert integers to bool there is a trick you can perform:

#include 
#include 

bool isittrue;
uint8_t n = 13;

isittrue = !!n;

13 is "true". So !13 is false and !!13 is therefore true.

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

Thanks Clawson, I will study this explanation and get back to you if I have questions. More to the point for me...

clawson wrote:
Quote:

Shouldn't this be in the avr-libc Reference Manual?

It is?!?

http://www.nongnu.org/avr-libc/u...

How did you know where to find this page? I went to these pages

http://www.nongnu.org/avr-libc/u... and
http://www.nongnu.org/avr-libc/u...

and there is nothing resembling a decent table of contents. Any tips on how to find your way around this document?

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

Quote:
What happens if you perform logical operations on "uint8" data?

While Cliffs answer above is corect, this question triggers me to give the following advice: You should get your hands on a good C textbook.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

JohanEkdahl wrote:

You should get your hands on a good C textbook.

Right, just as soon as I get my program written (humor).

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

bool who; 
uint8_t n = 13; 

who = !!n; 

!! who's there? (bad humor)

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

Last Edited: Mon. Jun 4, 2012 - 04:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
How did you know where to find this page? I went to these pages

http://www.nongnu.org/avr-libc/u... and
http://www.nongnu.org/avr-libc/u...


Download the manual in pdf format. There the searching is easier.
http://ugweb.cs.ualberta.ca/~c29...

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

larryvc wrote:

bool who;
uint8_t n = 13;

who = !!n; [/code]
!! who's there? (bad humor)

maybe bad humor but VERY funny

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

Somebody help me, I can't stop...

!!
who's there
bool
bool who
don't cry

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

jwriter wrote:
Somebody help me, I can't stop...

!!
who's there
bool
bool who
don't cry


!(! amusing)