which *int* ?

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.

If you must have an unsigned integer of size 32 bits, how would you code it up?

u32int
4
6%
uint32_t
30
42%
u32int_t
0
No votes
uint32
12
17%
unsigned int (I don't care about portability)
8
11%
something else
17
24%
 
Total votes: 71

User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: which *int* ?

Post by Solar »

Hobbes wrote:Smeezekitty apparently doesn't care about scalability or portability, but IMHO that's exactly the point of this topic.
There's a crucial difference between being aware of an issue and ignoring it, or being unaware of an issue.

He said he's using "unsigned long", and that's 100% OK with me. But "because I am in real mode" isn't the right kind of reason for such a decision, and "so in 16bit you use long to get 32 bits" is dangerous advice.
Every good solution is obvious once you've found it.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: which *int* ?

Post by qw »

Then again, is there a single C compiler in the world that produces 16 bits real mode code and does not define long as 32 bits?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: which *int* ?

Post by Combuster »

I do know one that does not define int as 16 bits...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: which *int* ?

Post by qw »

Combuster wrote:I do know one that does not define int as 16 bits...
Really? Which one is that?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: which *int* ?

Post by Combuster »

You're probably using it: GCC

(and please, google .code16gcc before attempting to fail :wink:)
Last edited by Combuster on Thu Oct 29, 2009 8:54 am, edited 1 time in total.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: which *int* ?

Post by qw »

GCC doesn't produce 16 bits real mode code, does it?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: which *int* ?

Post by Combuster »

Too late with the edit ](*,)

But you still failed. :D
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: which *int* ?

Post by Solar »

Last time I looked, there was some experimental, somewhat unreliable, not officially supported way to make GCC produce "pure" 16bit code mentioned in the GNU 'as' documentation (.code16gcc), but certainly nothing I would use outside the GCC maintenance team.
Every good solution is obvious once you've found it.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: which *int* ?

Post by qw »

Combuster,
Ah no, GCC still produces 32 bits code. The .code16gcc directive just tells GAS to add a32/o32 prefixes so it may run in 16 bits mode.

Solar,
D.J. Delorie did something like that: http://www.delorie.com/djgpp/16bit/gcc/.
Last edited by qw on Fri Oct 30, 2009 2:27 am, edited 1 time in total.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: which *int* ?

Post by Combuster »

@Solar, Counter-question: What's better supported: Turbo C++ 1.0 or .code16gcc? :)
Ah no, GCC still produces 32 bits code.
Ah the red herring. GCC emits binaries which run in 16 bit mode.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply