<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40"
xmlns:ns0="http://schemas.microsoft.com/office/2004/12/omml">
<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[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]--><o:SmartTagType
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--a:link
        {mso-style-priority: 99
;}
span.MSOHYPERLINK
        {mso-style-priority: 99
;}
a:visited
        {mso-style-priority: 99
;}
span.MSOHYPERLINKFOLLOWED
        {mso-style-priority: 99
;}
p.MSOPLAINTEXT
        {mso-style-priority: 99;}
li.MSOPLAINTEXT
        {mso-style-priority: 99;}
div.MSOPLAINTEXT
        {mso-style-priority: 99;}
p
        {mso-style-priority: 99
;}
span.PLAINTEXTCHAR
        {mso-style-priority: 99;}
/* Font Definitions */
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;}
@font-face
        {font-family:"Comic Sans MS";
        panose-1:3 15 7 2 3 3 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
p
        {mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.PlainTextChar
        {font-family:Consolas;}
p.PlainText, li.PlainText, div.PlainText
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:Arial;
        color:navy;}
span.EmailStyle22
        {mso-style-type:personal;
        font-family:"Comic Sans MS";
        color:navy;
        font-weight:normal;
        font-style:italic;
        text-decoration:none none;}
span.EmailStyle23
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:595.3pt 841.9pt;
        margin:3.0cm 2.0cm 3.0cm 2.0cm;}
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=DA link=blue vlink=blue>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>Thanks every one for all
the inputs.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>In this particular case,
I’ll make sure that it is not possible to make a memory leak. No clever
warning but can’t have it all. <o:p></o:p></span></font></p>
<div>
<p><font size=3 color=navy face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt;color:navy'>Med venlig hilsen / Best regards / mit
freundlichen Grüßen<o:p></o:p></span></font></p>
<p><b><font size=3 color=navy face="Times New Roman"><span style='font-size:
12.0pt;color:navy;font-weight:bold'>EC POWER A/S</span></font></b><font
color=navy><span style='color:navy'><o:p></o:p></span></font></p>
<p><st1:PersonName w:st="on"><b><font size=3 color=navy face="Times New Roman"><span
style='font-size:12.0pt;color:navy;font-weight:bold'>Steven Lose</span></font></b></st1:PersonName><font
color=navy><span style='color:navy'><o:p></o:p></span></font></p>
<p><font size=3 color=navy face="Times New Roman"><span style='font-size:12.0pt;
color:navy'>Software Ingeniør<o:p></o:p></span></font></p>
<p><font size=3 color=navy face="Times New Roman"><span style='font-size:12.0pt;
color:navy'>Tlf.: +45 87434100<o:p></o:p></span></font></p>
<p><font size=3 color=navy face="Times New Roman"><span style='font-size:12.0pt;
color:navy'>Direkte tlf. +45 58286608<o:p></o:p></span></font></p>
<p><font size=3 color=navy face="Times New Roman"><span style='font-size:12.0pt;
color:navy'>Email: <a href="blocked::mailto:bsl@ecpower.dk">sl@ecpower.dk</a><o:p></o:p></span></font></p>
<p><font size=3 color=navy face="Times New Roman"><span style='font-size:12.0pt;
color:navy'><a href="http://www.ecpower.dk">www.ecpower.dk</a></span></font><o:p></o:p></p>
</div>
<div>
<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>Fra:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
icc-avr-bounces@imagecraft.com [mailto:icc-avr-bounces@imagecraft.com] <b><span
style='font-weight:bold'>På vegne af </span></b>Albert van Veen<br>
<b><span style='font-weight:bold'>Sendt:</span></b> 6. juli 2007 05:41<br>
<b><span style='font-weight:bold'>Til:</span></b> Discussion list for ICCAVR
and ICCtiny Users. You do NOT needtosubscribeto icc-announce if you are a
member of this.<br>
<b><span style='font-weight:bold'>Emne:</span></b> RE: [Icc-avr] check for
adequately nr. of bits</span></font><o:p></o:p></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
<div>
<p class=MsoNormal><font size=3 color=blue face="Times New Roman"><span
lang=ES-AR style='font-size:12.0pt;color:blue'>Well, the way I have really
always done it, and has been compatible over all compilers I've used:</span></font><span
lang=ES-AR><o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=ES-AR
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 color=blue face="Times New Roman"><span
lang=ES-AR style='font-size:12.0pt;color:blue'>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;</span></font><span lang=ES-AR><o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><font size=3 color=blue face="Times New Roman"><span
lang=ES-AR style='font-size:12.0pt;color:blue'>Tbits flags1,flags2,latch_flags,defect_flags,extra_flags;
// as many as needed, named or numbered</span></font><span lang=ES-AR><o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=ES-AR
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 color=blue face="Times New Roman"><span
lang=ES-AR style='font-size:12.0pt;color:blue'>#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 ]</span></font><span
lang=ES-AR><o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=ES-AR
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 color=blue face="Times New Roman"><span
lang=ES-AR style='font-size:12.0pt;color:blue'>#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</span></font><span
lang=ES-AR><o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><font size=3 color=blue face="Times New Roman"><span
lang=ES-AR style='font-size:12.0pt;color:blue'>etc. etc.</span></font><span
lang=ES-AR><o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=ES-AR
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 color=blue face="Times New Roman"><span
lang=ES-AR style='font-size:12.0pt;color:blue'>Easy to set, clear, check:</span></font><span
lang=ES-AR><o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=ES-AR
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=ES-AR
style='font-size:12.0pt'> <font color=blue><span
style='color:blue'>if (in_ALA) recheck= true;</span></font><o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=ES-AR
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=ES-AR
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 color=blue face="Times New Roman"><span
lang=ES-AR style='font-size:12.0pt;color:blue'>AND VERY READABLE TOO !!</span></font><span
lang=ES-AR><o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=ES-AR
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 color=blue face="Times New Roman"><span
lang=ES-AR style='font-size:12.0pt;color:blue'>Greetings,</span></font><span
lang=ES-AR><o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><font size=3 color=blue face="Times New Roman"><span
lang=ES-AR style='font-size:12.0pt;color:blue'>Albert.</span></font><span
lang=ES-AR><o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=ES-AR
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 color=blue face="Times New Roman"><span
lang=ES-AR style='font-size:12.0pt;color:blue'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 color=blue face="Times New Roman"><span
lang=ES-AR style='font-size:12.0pt;color:blue'><o:p> </o:p></span></font></p>
</div>
<blockquote style='margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'>
<p class=MsoNormal style='margin-bottom:12.0pt'><font size=2 face=Tahoma><span
lang=ES-AR style='font-size:10.0pt;font-family:Tahoma'>-----Original
Message-----<br>
<b><span style='font-weight:bold'>From:</span></b> Ing. Abner Chamson
[mailto:mcreations@fibertel.com.ar]<br>
<b><span style='font-weight:bold'>Sent:</span></b> Friday, 6 July 2007 12:57
p.m.<br>
<b><span style='font-weight:bold'>To:</span></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><span style='font-weight:bold'>Subject:</span></b> RE: [Icc-avr] check for
adequately nr. of bits</span></font><span lang=ES-AR><o:p></o:p></span></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>Hi, I’m sort of a newbie in C.<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>Not a newbie perhaps in time, but yes in the fact that I
program occasionnaly…<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>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></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>Everytime I started a project I thougth “well, 8 flags
will be enough” and declared <o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>unsigned char ucflags<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'> #define FLAG1 BIT(0)<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>…<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>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></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>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></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>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></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>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></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>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></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>This is a sample code I did to test this:<o:p></o:p></span></font></i></p>
<div style='border:none;border-bottom:dotted windowtext 3.0pt;padding:0cm 0cm 1.0pt 0cm'>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>********************************<o:p></o:p></span></font></i></p>
<p class=MsoNormal><b><font size=2 color=black face="Courier New"><span
lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black;
font-weight:bold'>unsigned</span></font></b><font size=2 color=black
face="Courier New"><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";
color:black'> <b><span style='font-weight:bold'>char</span></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><span style='font-weight:bold'>signed</span></b> <b><span style='font-weight:
bold'>char</span></b> scfoo;<br>
<br>
<b><span style='font-weight:bold'>void</span></b> main(<b><span
style='font-weight:bold'>void</span></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></font><font size=2 color=green face="Courier New"><span
lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:green'>/*<br>
<br>
*/</span></font><font size=2 color=black face="Courier New"><span
lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'><br>
<br>
TOGGLE(FLAG1);<br>
TOGGLE(FLAG9);<br>
TOGGLE(FLAG11);<br>
TOGGLE(FLAG3);<br>
<br>
<b><span style='font-weight:bold'>if</span></b>(TEST(FLAG1))<br>
scfoo++;<br>
<b><span style='font-weight:bold'>else</span></b><br>
scfoo--; <br>
<br>
TOGGLE(FLAG1);<br>
<br>
}</span></font><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'><o:p></o:p></span></font></i></p>
</div>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'><o:p> </o:p></span></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>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></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>Does anyone know why is this?<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'><o:p> </o:p></span></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'>Ing. Abner Chamson<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'><a href="http://www.mcreations.com.ar">www.mcreations.com.ar</a><o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'><o:p> </o:p></span></font></i></p>
<p class=MsoNormal><i><font size=4 color=navy face="Comic Sans MS"><span
lang=EN-US style='font-size:14.0pt;font-family:"Comic Sans MS";color:navy;
font-style:italic'><o:p> </o:p></span></font></i></p>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>
<p class=MsoNormal><b><font size=2 face=Tahoma><span lang=EN-US
style='font-size:10.0pt;font-family:Tahoma;font-weight:bold'>From:</span></font></b><font
size=2 face=Tahoma><span lang=EN-US style='font-size:10.0pt;font-family:Tahoma'>
icc-avr-bounces@imagecraft.com [mailto:icc-avr-bounces@imagecraft.com] <b><span
style='font-weight:bold'>On Behalf Of </span></b><st1:PersonName w:st="on">Steven
Lose</st1:PersonName><br>
<b><span style='font-weight:bold'>Sent:</span></b> Jueves, 05 de Julio de 2007
06:31 p.m.<br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName w:st="on">Discussion
list for ICCAVR and ICCtiny Users. You do NOT need tosubscribeto icc-announce
if you are a member of this.</st1:PersonName><br>
<b><span style='font-weight:bold'>Subject:</span></b> SV: [Icc-avr] check for
adequately nr. of bits<o:p></o:p></span></font></p>
</div>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=ES-AR
style='font-size:12.0pt'><o:p> </o:p></span></font></p>
<p class=MsoNormal><a name=""><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>Hi John.</span></font></a><font
size=2 color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:navy'><o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>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></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>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></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>But…<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>An error message would be
so nice.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>Thanks.<o:p></o:p></span></font></p>
<div>
<p><font size=3 color=navy face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt;color:navy'>Med venlig hilsen / Best regards / mit
freundlich</span>en Grüßen<o:p></o:p></font></p>
<p><b><font size=3 color=navy face="Times New Roman"><span style='font-size:
12.0pt;color:navy;font-weight:bold'>EC POWER A/S</span></font></b><font
color=navy><span style='color:navy'><o:p></o:p></span></font></p>
<p><st1:PersonName w:st="on"><b><font size=3 color=navy face="Times New Roman"><span
style='font-size:12.0pt;color:navy;font-weight:bold'>Steven Lose</span></font></b></st1:PersonName><font
color=navy><span style='color:navy'><o:p></o:p></span></font></p>
<p><font size=3 color=navy face="Times New Roman"><span style='font-size:12.0pt;
color:navy'>Software Ingeniør<o:p></o:p></span></font></p>
<p><font size=3 color=navy face="Times New Roman"><span style='font-size:12.0pt;
color:navy'>Tlf.: +45 87434100<o:p></o:p></span></font></p>
<p><font size=3 color=navy face="Times New Roman"><span style='font-size:12.0pt;
color:navy'>Direkte tlf. +45 58286608<o:p></o:p></span></font></p>
<p><font size=3 color=navy face="Times New Roman"><span style='font-size:12.0pt;
color:navy'>Email: <a href="blocked::mailto:bsl@ecpower.dk">sl@ecpower.dk</a><o:p></o:p></span></font></p>
<p><font size=3 color=navy face="Times New Roman"><span style='font-size:12.0pt;
color:navy'><a href="http://www.ecpower.dk">www.ecpower.dk</a></span></font><o:p></o:p></p>
</div>
<div>
<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center>
</span></font></div>
<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>Fra:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
icc-avr-bounces@imagecraft.com [mailto:icc-avr-bounces@imagecraft.com] <b><span
style='font-weight:bold'>På vegne af </span></b>John Baraclough<br>
<b><span style='font-weight:bold'>Sendt:</span></b> 5. juli 2007 23:00<br>
<b><span style='font-weight:bold'>Til:</span></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><span style='font-weight:bold'>Emne:</span></b> RE: [Icc-avr] check for
adequately nr. of bits</span></font><o:p></o:p></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>You could indeed, but it
would be very unwise. Single bit flags should <b><span style='font-weight:bold'>always</span></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></font><font face="Courier New"><span 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>
<font color=green><span style='color:green'>// Flow control flags.<br>
</span></font>#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></font>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></p>
<p class=MsoNormal><font size=3 color=blue face="Times New Roman"><span
style='font-size:12.0pt;color:blue'>couldn't you simply say<br>
</span></font> <br>
<font color=blue><span style='color:blue'>#if </span></font><font size=2><span
style='font-size:10.0pt'>NROFFLAGS<17<br>
<br>
Unsigned int uiFlags;<br>
<br>
#else<br>
<br>
Unsigned long uiFlags;<br>
#endif<br>
</span></font> <br>
<font size=2><span style='font-size:10.0pt'>Albert<br>
</span></font> <br>
<o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>-----Original Message-----<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>From: Jaspers, Ton [<a
href="mailto:t.jaspers@cpseurope.com"> mailto:t.jaspers@cpseurope.com</a>]<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>Sent: Friday, 6 July 2007 12:45
a.m.<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>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></font></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face=Tahoma><span style='font-size:
10.0pt;font-family:Tahoma'>Subject: RE: [Icc-avr] check for adequately nr. of
bits</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>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></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2
face="Times New Roman"><span style='font-size:10.0pt'>
#include <limits.h></span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2
face="Times New Roman"><span style='font-size:10.0pt'> #define
NROFFLAGS 17</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2
face="Times New Roman"><span style='font-size:10.0pt'>
#if (1<<(NROFFLAGS-1)) > UINT_MAX</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
ERROR “VALUE TO SMALL” <o:p></o:p></span></font></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'> #endif</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2
face="Times New Roman"><span style='font-size:10.0pt'>Mind you, I have not
tried it.</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2
face="Times New Roman"><span style='font-size:10.0pt'>Cheers,<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2
face="Times New Roman"><span style='font-size:10.0pt'>Ton</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<div style='margin-left:36.0pt'>
<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center>
</span></font></div>
</div>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>From:
icc-avr-bounces@imagecraft.com [<a href="mailto:icc-avr-bounces@imagecraft.com">
mailto:icc-avr-bounces@imagecraft.com</a>] On Behalf Of <st1:PersonName w:st="on">Steven
Lose</st1:PersonName><o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>Sent: donderdag 5 juli 2007 12:59<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>To: <st1:PersonName w:st="on">Discussion
list for ICCAVR and ICCtiny Users. You do NOT need tosubscribeto icc-announce
if you are a member of this.</st1:PersonName><o:p></o:p></span></font></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face=Tahoma><span style='font-size:
10.0pt;font-family:Tahoma'>Subject: [Icc-avr] check for adequately nr. of bits</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'>Hi.</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'> </span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'>I want to make the linker check that a variable is
defined big enough, but don’t know how.</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'> </span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'>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></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'> </span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'>#define NROFFLAGS 17</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'> </span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'>Unsigned int uiFlags;</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'> </span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'>#if NROFFLAGS > NROFBITS(uiFlags)</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'> ERROR “VALUE TO SMALL”</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'>#endif</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'> </span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'>Is it possible to do so? (if it had been in code I
would just use (sizeof(uiFlags)*8) )</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'>And if yes, what is the right way to do it?</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'> </span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>Med venlig hilsen / Best regards / mit freundlichen
Grüßen<o:p></o:p></span></font></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=3 color=navy face="Times New Roman"><span
style='font-size:12.0pt;color:navy'>EC POWER A/S</span></font><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><st1:PersonName w:st="on"><font size=3 color=navy
face="Times New Roman"><span style='font-size:12.0pt;color:navy'>Steven Lose</span></font></st1:PersonName><o:p></o:p></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>Software Ingeniør<o:p></o:p></span></font></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>Tlf.: +45 87434100<o:p></o:p></span></font></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>Direkte tlf. +45 58286608<o:p></o:p></span></font></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>Email: <a href="blocked::mailto:bsl@ecpower.dk">sl@ecpower.dk</a><o:p></o:p></span></font></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'><a href="http://www.ecpower.dk/">www.ecpower.dk</a><o:p></o:p></span></font></p>
<p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:
12.0pt;margin-left:36.0pt'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>_______________________________________________<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></font></p>
</blockquote>
</div>
</body>
</html>