gnupic: Bit variables in C


Previous by date: 15 Nov 2000 04:28:27 -0000 Re: Bit variables in C, Matt
Next by date: 15 Nov 2000 04:28:27 -0000 Re: Bit variables in C, Alex Holden
Previous in thread: 15 Nov 2000 04:28:27 -0000 Re: Bit variables in C, Matt
Next in thread: 15 Nov 2000 04:28:27 -0000 Re: Bit variables in C, Alex Holden

Subject: Re: Bit variables in C
From: Mike ####@####.####
Date: 15 Nov 2000 04:28:27 -0000
Message-Id: <20001114232957.A21767@earthlink.net>

Scott Dattalo wrote:
> 
> It's not part of ANSI, but SDCC has support for a `bit' type. This makes sense
> if your target MCU is an 8051 (because of the bit instructions). However, how
> useful is it for the PIC? I'd personally stay away from it since it is not
> portable. OTOH, I'm probably going to keep it in since it's already part of
> SDCC. Any opinions?

Well, it's not quite a bit type, but according to K&R ANSI C does have
support for a bit-field type.  Could this somehow be used in someway to
provide some sort of portability?

Quick synopsis:

struct {
  unsigned int flag_a : 1;
  unsigned int flag_b : 1;
  unsigned int flag_c : 1;
} flags;

This defines a variable 'flags' that contains three 1-bit fields.  I don't
see why it couldn't be used for single 1-bit flags as well.  Perhaps via a
typedef or a macro somehow?

Perhaps I should point out that I am very much still a beginner at coding,
and so may well be talking out my arse here.  So if this isn't possible, I
won't be too surprised. ;)
-- 
Mike Werner  KA8YSD   | He that is slow to believe anything and
                      | everything is of great understanding,
'91 GS500E            | for belief in one false principle is the
Morgantown WV         | beginning of all unwisdom.


[Content type application/pgp-signature not shown. Download]

Previous by date: 15 Nov 2000 04:28:27 -0000 Re: Bit variables in C, Matt
Next by date: 15 Nov 2000 04:28:27 -0000 Re: Bit variables in C, Alex Holden
Previous in thread: 15 Nov 2000 04:28:27 -0000 Re: Bit variables in C, Matt
Next in thread: 15 Nov 2000 04:28:27 -0000 Re: Bit variables in C, Alex Holden


Powered by ezmlm-browse 0.20.