What did you name your integer types? (and other questions)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
tkahn6
Posts: 11
Joined: Sat Jul 11, 2009 5:14 pm

What did you name your integer types? (and other questions)

Post 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!
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Re: What did you name your integer types? (and other questions)

Post 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.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: What did you name your integer types? (and other questions)

Post 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 :mrgreen:

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.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
tkahn6
Posts: 11
Joined: Sat Jul 11, 2009 5:14 pm

Re: What did you name your integer types? (and other questions)

Post 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_* :-)
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: What did you name your integer types? (and other questions)

Post 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?) ;-)
Every good solution is obvious once you've found it.
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: What did you name your integer types? (and other questions)

Post 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.
Post Reply