www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/02/15/01:44:35

From: "Andrew Jones" <luminous-is AT home DOT com>
Newsgroups: comp.os.msdos.djgpp
References: <saeug83qivs52 AT corp DOT supernews DOT com>
Subject: Re: 256 variable holder... Quick Question!
Lines: 29
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
Message-ID: <nm4q4.45704$45.2399588@news2.rdc1.on.home.com>
Date: Tue, 15 Feb 2000 04:12:03 GMT
NNTP-Posting-Host: 24.42.120.18
X-Complaints-To: abuse AT home DOT net
X-Trace: news2.rdc1.on.home.com 950587923 24.42.120.18 (Mon, 14 Feb 2000 20:12:03 PST)
NNTP-Posting-Date: Mon, 14 Feb 2000 20:12:03 PST
Organization: @Home Network Canada
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

> Okay, I need a variable that stores no more than 256. I used to use this to
> hold a number anywhere from 0 to 255;
>     unsigned __int8 varname;
>     varname = 255;
> It worked well and was very fast. But, this does not work in DJGPP. The
> smallest type I can use is a SHORT INT which is too slow for a graphics
> display, and a waste since I only use 256 colors. I need something like
> __INT8 to store numbers, but now it's gone. Any explanation is welcome, but
> if it gets complicated, please be thorough. I just now broke into the DJGPP
> scene.

I am not too sure which C compiler defines a data type of __int8 (has to be
windows... ).

Try this

typedef __int8 char;
typedef __int16 short int;
typedef __int32 long int;

stick this in a header file that's included by all source files that use this
notation.  You will now have pseudo-variable types with these names.
Or just do what most real programmers would, and use unsigned char.  The
typedefs are handy for portability across different sized architechtures,
though.

AndrewJ


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019