Page 1 of 1
What did you name your integer types? (and other questions)
Posted: Sun Jul 12, 2009 6:35 pm
by tkahn6
So, I'm implementing my versions of std(lib|io) functions and I was wondering what you guys named your integer types.
I did some tests on my processor (Intel Celeron) and some research online and I discovered the following:
Code: Select all
Type Size
-----------|---------------
char | 1 byte
short | 2 bytes
int | 4 bytes
long | 4 bytes
So,
1) Does this look correct?
2)
Did you name your integer types?
3) Isn't it cool that sizeof is built in operator?
Also:
After I get some basic i/o working (by i/o I mean printf), I think I need to get/create/define an Interrupt Descriptor Table. How did you get yours working and if you could, would you mind recommending some article or tutorial I could look at to get me started? I believe I know roughly what it is, but a resource explaining how to implement it would be really helpful.
Thanks guys!
Re: What did you name your integer types? (and other questions)
Posted: Sun Jul 12, 2009 7:03 pm
by 01000101
1: it looks fine
2:
Code: Select all
uint8_t | unsigned char
uint16_t | unsigned short
uint32_t | unsigned int
uint64_t | unsigned long long
size_t | unsigned long
3: yes it is, I use it often.
Re: What did you name your integer types? (and other questions)
Posted: Sun Jul 12, 2009 11:06 pm
by Troy Martin
1. Looks good.
2. size_t = unsigned long, u8int = unsigned char, u16int = unsigned short, u32int = unsigned int.
3. It's a real useful function, especially for finding struct sizes and such.
tkahn6 wrote:After I get some basic i/o working (by i/o I mean printf), I think I need to get/create/define an Interrupt Descriptor Table. How did you get yours working and if you could, would you mind recommending some article or tutorial I could look at to get me started? I believe I know roughly what it is, but a resource explaining how to implement it would be really helpful.
IDT
Here
BTW, printf() requires a va_list and the va_ functions, and gcc can easily do that for you via the __builtin_va_ defines (just use a #define to make the va_ defines use __builtin_va_), as long as you know how to use variable argument lists.
Re: What did you name your integer types? (and other questions)
Posted: Sun Jul 12, 2009 11:23 pm
by tkahn6
Troy Martin wrote:
BTW, printf() requires a va_list and the va_ functions, and gcc can easily do that for you via the __builtin_va_ defines (just use a #define to make the va_ defines use __builtin_va_), as long as you know how to use variable argument lists.
Thanks for recommending this. I was going to use another set of macros but letting gcc do this for me is waaay better.
The reason I realised I needed to implement a naming convention for my integer types was because of va_*
Re: What did you name your integer types? (and other questions)
Posted: Mon Jul 13, 2009 12:16 am
by Solar
tkahn6 wrote:So, I'm implementing my versions of std(lib|io) functions and I was wondering what you guys named your integer types.
The way stdint.h demands.
(Little sense in thinking up your own names in
addition to those defined by stdint.h, no?)
Re: What did you name your integer types? (and other questions)
Posted: Mon Jul 13, 2009 8:43 am
by quok
Solar wrote:tkahn6 wrote:So, I'm implementing my versions of std(lib|io) functions and I was wondering what you guys named your integer types.
The way stdint.h demands.
(Little sense in thinking up your own names in
addition to those defined by stdint.h, no?)
Solar++.
I also name my integer types the way stdint.h demands. I find things like u8int and u_int8_t to just be rather silly. stdint.h is a C99 specified header file, so I find no reason to name my integer types anything else. I find it makes it much easier for anyone else to follow the code.