<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v =
"urn:schemas-microsoft-com:vml" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word" xmlns:m =
"http://schemas.microsoft.com/office/2004/12/omml"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.3132" name=GENERATOR><!--[if !mso]>
<STYLE>v\:* {
        BEHAVIOR: url(#default#VML)
}
o\:* {
        BEHAVIOR: url(#default#VML)
}
w\:* {
        BEHAVIOR: url(#default#VML)
}
.shape {
        BEHAVIOR: url(#default#VML)
}
</STYLE>
<![endif]-->
<STYLE>@font-face {
        font-family: Cambria Math;
}
@font-face {
        font-family: Calibri;
}
@font-face {
        font-family: Tahoma;
}
@font-face {
        font-family: Consolas;
}
@font-face {
        font-family: Comic Sans MS;
}
@page Section1 {size: 595.3pt 841.9pt; margin: 3.0cm 2.0cm 3.0cm 2.0cm; }
P.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman","serif"
}
LI.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman","serif"
}
DIV.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman","serif"
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
A:visited {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlinkFollowed {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
P.MsoPlainText {
        FONT-SIZE: 10pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Courier New"; mso-style-priority: 99; mso-style-link: "Plain Text Char"
}
LI.MsoPlainText {
        FONT-SIZE: 10pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Courier New"; mso-style-priority: 99; mso-style-link: "Plain Text Char"
}
DIV.MsoPlainText {
        FONT-SIZE: 10pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Courier New"; mso-style-priority: 99; mso-style-link: "Plain Text Char"
}
P {
        FONT-SIZE: 12pt; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm; FONT-FAMILY: "Times New Roman","serif"; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-style-priority: 99
}
SPAN.PlainTextChar {
        FONT-FAMILY: Consolas; mso-style-priority: 99; mso-style-link: "Plain Text"; mso-style-name: "Plain Text Char"
}
SPAN.EmailStyle20 {
        COLOR: navy; FONT-FAMILY: "Arial","sans-serif"; mso-style-type: personal
}
SPAN.EmailStyle21 {
        FONT-WEIGHT: normal; COLOR: navy; FONT-STYLE: italic; FONT-FAMILY: "Comic Sans MS"; TEXT-DECORATION: none; mso-style-type: personal-reply
}
.MsoChpDefault {
        FONT-SIZE: 10pt; mso-style-type: export-only
}
DIV.Section1 {
        page: Section1
}
</STYLE>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></HEAD>
<BODY lang=ES-AR vLink=blue link=blue>
<DIV><SPAN class=921033403-06072007><FONT color=#0000ff>Well, the way I have
really always done it, and has been compatible over all compilers I've
used:</FONT></SPAN></DIV>
<DIV><SPAN class=921033403-06072007><FONT
color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN class=921033403-06072007><FONT color=#0000ff>typedef struct
{<BR> unsigned b0: 1;<BR> unsigned b1: 1;<BR> unsigned b2:
1;<BR> unsigned b3: 1;<BR> unsigned b4: 1;<BR> unsigned b5:
1;<BR> unsigned b6: 1;<BR> unsigned b7: 1;<BR>}
Tbits;<BR></FONT></SPAN></DIV>
<DIV><SPAN class=921033403-06072007><FONT color=#0000ff>Tbits
flags1,flags2,latch_flags,defect_flags,extra_flags; // as many as needed,
named or numbered</FONT></SPAN></DIV>
<DIV><SPAN class=921033403-06072007><FONT
color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN class=921033403-06072007><FONT color=#0000ff>#define
kiwi flags1.0<BR>#define
piezo_fast flags1.1<BR>#define
new_tick flags1.2<BR>#define walk_wait flags1.3<BR>#define
in_24hr_test flags1.4<BR>#define wait_for_ext flags1.5<BR>#define
keyclick flags1.6<BR>#define
pressed flags1.7 // any button<BR>#define
interlock1 flags2.0 // switches/ext.interl.<BR>#define
interlock2 flags2.1 // mains / e2<BR>#define
combi flags2.2<BR>#define tmp_flag flags2.3 //
local only<BR>#define in_ALA flags2.3 // (in zone
a/d)<BR>#define recheck flags2.4 // status of switches
(MUX1)<BR>#define flash flags2.5 // global fire led
(Aus)<BR>#define real_alarm flags2.6 // [ to cancel<BR>#define
test_active flags2.7 // test alarm
]</FONT></SPAN></DIV>
<DIV><FONT color=#0000ff></FONT> </DIV>
<DIV><SPAN class=921033403-06072007><FONT color=#0000ff>#define
pcb_defect_latch latch_flags.0 /* these latch */<BR>#define
leds_defect_latch latch_flags.1<BR>#define
door_defect_latch latch_flags.2<BR>#define
extern_def_latch latch_flags.3<BR>#define spr_latch
latch_flags.4 // NZ<BR>#define auxm_latch
latch_flags.4 // Aus<BR>#define
earth_defect_latch latch_flags.5<BR>#define battery_latch
latch_flags.6<BR>#define charger_latch
latch_flags.7<BR></FONT></SPAN></DIV>
<DIV><SPAN class=921033403-06072007><FONT color=#0000ff>etc.
etc.</FONT></SPAN></DIV>
<DIV><SPAN class=921033403-06072007><FONT
color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN class=921033403-06072007><FONT color=#0000ff>Easy to set, clear,
check:</FONT></SPAN></DIV>
<DIV><SPAN class=921033403-06072007><FONT
color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN class=921033403-06072007> <FONT color=#0000ff>if
(in_ALA) recheck= true;</FONT></SPAN></DIV>
<DIV><SPAN class=921033403-06072007><FONT
color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN class=921033403-06072007><FONT
color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN class=921033403-06072007><FONT color=#0000ff>AND VERY READABLE TOO
!!</FONT></SPAN></DIV>
<DIV><SPAN class=921033403-06072007><FONT
color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN class=921033403-06072007><FONT
color=#0000ff>Greetings,</FONT></SPAN></DIV>
<DIV><SPAN class=921033403-06072007><FONT
color=#0000ff>Albert.</FONT></SPAN></DIV>
<DIV><SPAN class=921033403-06072007></SPAN> </DIV>
<DIV><SPAN class=921033403-06072007><FONT color=#0000ff> </DIV>
<DIV><BR></DIV></FONT></SPAN>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Ing. Abner Chamson
[mailto:mcreations@fibertel.com.ar]<BR><B>Sent:</B> Friday, 6 July 2007 12:57
p.m.<BR><B>To:</B> 'Discussion list for ICCAVR and ICCtiny Users. You do NOT
need to subscribe to icc-announce if you are a member of
this.'<BR><B>Subject:</B> RE: [Icc-avr] check for adequately nr. of
bits<BR><BR></FONT></DIV>
<DIV class=Section1>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">Hi, I’m
sort of a newbie in C.<o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">Not a
newbie perhaps in time, but yes in the fact that I program
occasionnaly…<o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">This
discussion coincided for me with the start of a project where I know I’ll have
lots of flags, and wanted something to manage them.<o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">Everytime I
started a project I thougth “well, 8 flags will be enough” and declared
<o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">unsigned
char ucflags<o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'"> #define
FLAG1 BIT(0)<o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">…<o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">then, each
time i wanted to set, reset or test this flag I worked on the bit(0) of
ucflags<o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">but when I
had more than 8 flags, then I have to create another char named ucflags2 and
each time I have to work on a specific flag I have to remember if it
corresponds to ucflags or ucflags2…<o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">viewing
this list, I realized I had to define 3 or 4 Macros for each flag: SET, CLEAR,
TOGGLE and TEST <o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">As for the
container for those flags, I thought using an array of unsigned char whose
length would be the ceiling of NR_OF_FLAGS / 8<o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">Then each
flag is represented with two parameters, the group to which it corresponds and
the position in this byte<o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">This is a
sample code I did to test this:<o:p></o:p></SPAN></I></P>
<DIV
style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0cm; BORDER-TOP: medium none; PADDING-LEFT: 0cm; PADDING-BOTTOM: 1pt; BORDER-LEFT: medium none; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 3pt dotted; mso-element: para-border-div">
<P class=MsoNormal
style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0cm; BORDER-TOP: medium none; PADDING-LEFT: 0cm; PADDING-BOTTOM: 0cm; BORDER-LEFT: medium none; PADDING-TOP: 0cm; BORDER-BOTTOM: medium none"><I><SPAN
lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">********************************<o:p></o:p></SPAN></I></P>
<P class=MsoNormal
style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0cm; BORDER-TOP: medium none; PADDING-LEFT: 0cm; PADDING-BOTTOM: 0cm; BORDER-LEFT: medium none; PADDING-TOP: 0cm; BORDER-BOTTOM: medium none"><B><SPAN
lang=EN-US
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'">unsigned</SPAN></B><SPAN
lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'">
<B>char</B> ucflags[2];<BR> #define FLAG1
0,0
<BR> #define FLAG2 0,1<BR> #define FLAG3 0,2<BR> #define FLAG4
0,3<BR> #define FLAG5 0,4<BR> #define FLAG6 0,5<BR> #define
FLAG7 0,6<BR> #define FLAG8 0,7<BR> #define FLAG9
1,0<BR> #define FLAG10 1,1<BR> #define FLAG11 1,2<BR> #define
FLAG12 1,3<BR> #define FLAG13 1,4<BR> #define FLAG14
1,5<BR> #define FLAG15 1,6<BR> <BR> <BR>#define _SET(x,y)
(ucflags[x] |= 1<<y)<BR>#define SET(token) _SET(token)<BR><BR>#define
_CLEAR(x,y) (ucflags[x] &= ~(1<<y))<BR>#define CLEAR(token)
_CLEAR(token)<BR><BR>#define _TOGGLE(x,y) (ucflags[x] ^=
(1<<y))<BR>#define TOGGLE(token) _TOGGLE(token)<BR><BR>#define
_TEST(x,y) (ucflags[x] & 1<<y)<BR>#define TEST(token)
_TEST(token)<BR><B>signed</B> <B>char</B> scfoo;<BR><BR><B>void</B>
main(<B>void</B>)<BR>{<BR> SET(FLAG1);<BR> SET(FLAG9);<BR> SET(FLAG11);<BR> _SET(0,2);<BR> <BR> CLEAR(FLAG1);<BR> CLEAR(FLAG9);<BR> CLEAR(FLAG11);<BR> </SPAN><SPAN
lang=EN-US
style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'">/*<BR><BR>
*/</SPAN><SPAN lang=EN-US
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'"><BR><BR> TOGGLE(FLAG1);<BR> TOGGLE(FLAG9);<BR> TOGGLE(FLAG11);<BR> TOGGLE(FLAG3);<BR>
<BR> <B>if</B>(TEST(FLAG1))<BR>
scfoo++;<BR> <B>else</B><BR> scfoo--; <BR>
<BR> TOGGLE(FLAG1);<BR>
<BR>}</SPAN><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'"><o:p></o:p></SPAN></I></P></DIV>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'"><o:p> </o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">This has
been obtained by trial and error and there are things that I´m not sure why
they have to be that way. For example at first I had only defined the macro
_SET(x,y) and if I called it _SET(FLAG1) expecting that FLAG1 would be
replaced by 0,0 it complained about a mismatch in the number of arguments,
however if I call first SET(FLAG1) and then this macro calls _SET then the
arguments are correctly 0,0<o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">Does anyone
know why is this?<o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'"><o:p> </o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">Ing. Abner
Chamson<o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'"><A
href="http://www.mcreations.com.ar">www.mcreations.com.ar</A><o:p></o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'"><o:p> </o:p></SPAN></I></P>
<P class=MsoNormal><I><SPAN lang=EN-US
style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: 'Comic Sans MS'"><o:p> </o:p></SPAN></I></P>
<DIV>
<DIV
style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0cm; BORDER-TOP: #b5c4df 1pt solid; PADDING-LEFT: 0cm; PADDING-BOTTOM: 0cm; BORDER-LEFT: medium none; PADDING-TOP: 3pt; BORDER-BOTTOM: medium none">
<P class=MsoNormal><B><SPAN lang=EN-US
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">From:</SPAN></B><SPAN
lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">
icc-avr-bounces@imagecraft.com [mailto:icc-avr-bounces@imagecraft.com] <B>On
Behalf Of </B>Steven Lose<BR><B>Sent:</B> Jueves, 05 de Julio de 2007 06:31
p.m.<BR><B>To:</B> Discussion list for ICCAVR and ICCtiny Users. You do NOT
need tosubscribeto icc-announce if you are a member of
this.<BR><B>Subject:</B> SV: [Icc-avr] check for adequately nr. of
bits<o:p></o:p></SPAN></P></DIV></DIV>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal><A name=""><SPAN lang=DA
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: 'Arial','sans-serif'">Hi
John.</SPAN></A><SPAN lang=DA
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: 'Arial','sans-serif'"><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN lang=DA
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: 'Arial','sans-serif'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: 'Arial','sans-serif'">Alright,
it’s not that I use more than 8 flags at the moment, but I thought that at
some point in time someone may in the other module raise the defined nr. that
in this module is the reason for the nr. of flags needed. And then I have a
memory leak.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: 'Arial','sans-serif'">So the
easiest way is only to accept inputs < 8 for the flag function. And then
hope that it will become very clear that more space is needed when the SW
change does not work. <o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: 'Arial','sans-serif'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: 'Arial','sans-serif'">But…<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: 'Arial','sans-serif'">An
error message would be so nice.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: 'Arial','sans-serif'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: 'Arial','sans-serif'">Thanks.<o:p></o:p></SPAN></P>
<DIV>
<P><SPAN lang=EN-GB style="COLOR: navy">Med venlig hilsen / Best regards / mit
freundlich</SPAN><SPAN lang=DA style="COLOR: navy">en
Grüßen<o:p></o:p></SPAN></P>
<P><B><SPAN lang=DA style="COLOR: navy">EC POWER A/S</SPAN></B><SPAN lang=DA
style="COLOR: navy"><o:p></o:p></SPAN></P>
<P><B><SPAN lang=DA style="COLOR: navy">Steven Lose</SPAN></B><SPAN lang=DA
style="COLOR: navy"><o:p></o:p></SPAN></P>
<P><SPAN lang=DA style="COLOR: navy">Software Ingeniør<o:p></o:p></SPAN></P>
<P><SPAN lang=DA style="COLOR: navy">Tlf.: +45 87434100<o:p></o:p></SPAN></P>
<P><SPAN lang=DA style="COLOR: navy">Direkte tlf. +45
58286608<o:p></o:p></SPAN></P>
<P><SPAN lang=DA style="COLOR: navy">Email: <A
href="blocked::mailto:bsl@ecpower.dk">sl@ecpower.dk</A><o:p></o:p></SPAN></P>
<P><SPAN lang=DA style="COLOR: navy"><A
href="http://www.ecpower.dk">www.ecpower.dk</A></SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P></DIV>
<DIV>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><SPAN lang=DA>
<HR align=center width="100%" SIZE=2>
</SPAN></DIV>
<P class=MsoNormal><B><SPAN lang=DA
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">Fra:</SPAN></B><SPAN
lang=DA style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">
icc-avr-bounces@imagecraft.com [mailto:icc-avr-bounces@imagecraft.com] <B>På
vegne af </B>John Baraclough<BR><B>Sendt:</B> 5. juli 2007
23:00<BR><B>Til:</B> Discussion list for ICCAVR and ICCtiny Users. You do NOT
need tosubscribe to icc-announce if you are a member of this.<BR><B>Emne:</B>
RE: [Icc-avr] check for adequately nr. of bits</SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P></DIV>
<P class=MsoNormal><SPAN lang=DA><o:p> </o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-BOTTOM: 12pt"><SPAN lang=DA>You could indeed,
but it would be very unwise. Single bit flags should <B>always</B> be stored
in 8-bit variables, otherwise there is a very large overhead in setting,
clearing or testing any flag. This is the way I define flag macros for fastest
execution:<BR><BR></SPAN><SPAN lang=DA
style="FONT-FAMILY: 'Courier New'">#include <macros.h><BR><BR>#define
SCR_BIT
0<BR>#define
RUN_BIT
1<BR>#define
SEN_BIT
2<BR>#define
CHA_BIT
3<BR>#define
UPD_BIT
4<BR><BR><SPAN style="COLOR: green">// Flow control flags.<BR></SPAN>#define
TEST_SCREEN_FLAG
gucFlags&BIT(SCR)<BR>#define
SET_SCREEN_FLAG
gucFlags|=BIT(SCR)<BR>#define
CLEAR_SCREEN_FLAG
gucFlags&=~BIT(SCR)<BR><BR>#define
TEST_RUN_FLAG
gucFlags&BIT(RUN)<BR>#define
SET_RUN_FLAG
gucFlags|=BIT(RUN)<BR>#define
CLEAR_RUN_FLAG
gucFlags&=~BIT(RUN)<BR><BR>#define
TEST_SEND_FLAG
gucFlags&BIT(SEN)<BR>#define
SET_SEND_FLAG
gucFlags|=BIT(SEN)<BR>#define
CLEAR_SEND_FLAG
gucFlags&=~BIT(SEN)<BR><BR>#define
TEST_CHANGE_FLAG
gucFlags&BIT(CHA)<BR>#define
SET_CHANGE_FLAG
gucFlags|=BIT(CHA)<BR>#define
CLEAR_CHANGE_FLAG
gucFlags&=~BIT(CHA)<BR><BR>#define
TEST_UPDATE_FLAG
gucFlags&BIT(UPD)<BR>#define
SET_UPDATE_FLAG
gucFlags|=BIT(UPD)<BR>#define
CLEAR_UPDATE_FLAG
gucFlags&=~BIT(UPD)<BR><BR></SPAN><SPAN lang=DA>Whichever way you choose,
stay with 8-bit variable as the holders for flags.<BR><BR>HTH<BR><BR>All the
best for now,<BR>John<BR><BR>At 21:13 05/07/2007, you
wrote:<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN lang=DA style="COLOR: blue">couldn't you simply
say<BR></SPAN><SPAN lang=DA> <BR><SPAN style="COLOR: blue">#if
</SPAN></SPAN><SPAN lang=DA
style="FONT-SIZE: 10pt">NROFFLAGS<17<BR><BR>Unsigned int
uiFlags;<BR><BR>#else<BR><BR>Unsigned long uiFlags;<BR>#endif<BR></SPAN><SPAN
lang=DA> <BR></SPAN><SPAN lang=DA
style="FONT-SIZE: 10pt">Albert<BR></SPAN><SPAN
lang=DA> <BR> <o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN lang=DA
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">-----Original
Message-----<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN lang=DA
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">From: Jaspers, Ton
[<A href="mailto:t.jaspers@cpseurope.com">
mailto:t.jaspers@cpseurope.com</A>]<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN lang=DA
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">Sent: Friday, 6
July 2007 12:45 a.m.<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN lang=DA
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">To: Discussion
list for ICCAVR and ICCtiny Users. You do NOT need to subscribeto icc-announce
if you are a member of this.<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">Subject:
RE: [Icc-avr] check for adequately nr. of bits</SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN lang=DA>I don't think it is
a linker issue. It is a coding issue. You could try to use teh pre-processor
with something like this:<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN
lang=DA> <o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN lang=DA
style="FONT-SIZE: 10pt"> #include
<limits.h></SPAN><SPAN lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN
lang=DA> <o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN lang=DA
style="FONT-SIZE: 10pt"> #define NROFFLAGS 17</SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN
lang=DA> <o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN lang=DA
style="FONT-SIZE: 10pt"> #if (1<<(NROFFLAGS-1))
> UINT_MAX</SPAN><SPAN lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN
lang=DA> ERROR “VALUE TO SMALL”
<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt"> #endif</SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN lang=DA
style="FONT-SIZE: 10pt">Mind you, I have not tried it.</SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN
lang=DA> <o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN lang=DA
style="FONT-SIZE: 10pt">Cheers,<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN lang=DA
style="FONT-SIZE: 10pt">Ton</SPAN><SPAN lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN
lang=DA> <o:p></o:p></SPAN></P>
<DIV style="MARGIN-LEFT: 36pt">
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><SPAN lang=DA>
<HR align=center width="100%" SIZE=2>
</SPAN></DIV></DIV>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN lang=DA
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">From:
icc-avr-bounces@imagecraft.com [<A
href="mailto:icc-avr-bounces@imagecraft.com">
mailto:icc-avr-bounces@imagecraft.com</A>] On Behalf Of Steven
Lose<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN lang=DA
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">Sent: donderdag 5
juli 2007 12:59<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 36pt"><SPAN lang=DA
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">To: Discussion
list for ICCAVR and ICCtiny Users. You do NOT need tosubscribeto icc-announce
if you are a member of this.<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">Subject:
[Icc-avr] check for adequately nr. of bits</SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt">Hi.</SPAN><SPAN lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt"> </SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt">I want to make the linker check that a
variable is defined big enough, but don’t know how.</SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt"> </SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt">Basically I need something that tells me how
many bits there is in a variable so I can check it up against a defined
value.</SPAN><SPAN lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt"> </SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt">#define NROFFLAGS 17</SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt"> </SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt">Unsigned int uiFlags;</SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt"> </SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt">#if NROFFLAGS >
NROFBITS(uiFlags)</SPAN><SPAN lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt"> ERROR “VALUE TO SMALL”</SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt">#endif</SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt"> </SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt">Is it possible to do so? (if it had been in
code I would just use (sizeof(uiFlags)*8) )</SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt">And if yes, what is the right way to do
it?</SPAN><SPAN lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="FONT-SIZE: 10pt"> </SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA>Med venlig hilsen / Best regards / mit freundlichen
Grüßen<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="COLOR: navy">EC POWER A/S</SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA style="COLOR: navy">Steven Lose</SPAN><SPAN
lang=DA><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA>Software Ingeniør<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA>Tlf.: +45 87434100<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA>Direkte tlf. +45 58286608<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA>Email: <A
href="blocked::mailto:bsl@ecpower.dk">sl@ecpower.dk</A><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA><A
href="http://www.ecpower.dk/">www.ecpower.dk</A><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 36pt; MARGIN-RIGHT: 0cm; mso-margin-top-alt: 0cm"><SPAN
lang=DA> <o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
lang=DA>_______________________________________________<BR>Icc-avr mailing
list<BR>Icc-avr@imagecraft.com<BR><A
href="http://dragonsgate.net/mailman/listinfo/icc-avr">http://dragonsgate.net/mailman/listinfo/icc-avr</A><o:p></o:p></SPAN></P></DIV></BLOCKQUOTE></BODY></HTML>