<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=296280423-05072007><FONT color=#0000ff>I totally agree and
would always do it like that; I was just responding directly to the question
asked.</FONT></SPAN></DIV>
<DIV><SPAN class=296280423-05072007><FONT
color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN class=296280423-05072007><FONT color=#0000ff>BTW: shouldn't you be
going to bed on your side of the world?</FONT></SPAN></DIV>
<DIV><SPAN class=296280423-05072007><FONT
color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN class=296280423-05072007><FONT
color=#0000ff>Albert.</FONT></SPAN></DIV>
<DIV><SPAN class=296280423-05072007></SPAN> </DIV>
<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> John Baraclough
[mailto:j_baraclough@zetnet.co.uk]<BR><B>Sent:</B> Friday, 6 July 2007 9:00
a.m.<BR><B>To:</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>Subject:</B> RE: [Icc-avr] check for adequately nr. of
bits<BR><BR></FONT></DIV>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><FONT
face="Courier New, Courier">#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><FONT face="Courier New, Courier" color=#008000>// Flow
control flags.<BR></FONT><FONT face="Courier New, Courier">#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></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:<BR>
<BLOCKQUOTE class=cite cite="" type="cite"><FONT color=#0000ff>couldn't you
simply say<BR></FONT> <BR><FONT color=#0000ff>#if </FONT><FONT
size=2>NROFFLAGS<17<BR><BR>Unsigned int
uiFlags;<BR><BR>#else<BR><BR>Unsigned long
uiFlags;<BR>#endif<BR></FONT> <BR><FONT
size=2>Albert<BR></FONT> <BR> <BR>
<DL>
<DD><FONT face=Tahoma size=2>-----Original Message-----<BR>
<DD>From:</B> Jaspers, Ton [<A href="mailto:t.jaspers@cpseurope.com"
eudora="autourl"> mailto:t.jaspers@cpseurope.com</A>]<BR>
<DD>Sent:</B> Friday, 6 July 2007 12:45 a.m.<BR>
<DD>To:</B> Discussion list for ICCAVR and ICCtiny Users. You do NOT need
to subscribeto icc-announce if you are a member of this.<BR>
<DD>Subject:</B> RE: [Icc-avr] check for adequately nr. of
bits<BR><BR></FONT>
<DD>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:<BR>
<DD><BR>
<DD><FONT size=2> #include <limits.h><BR></FONT>
<DD><BR>
<DD><FONT size=2> #define NROFFLAGS 17<BR></FONT>
<DD><BR>
<DD><FONT size=2> #if (1<<(NROFFLAGS-1))
> UINT_MAX<BR></FONT>
<DD> ERROR “VALUE TO SMALL” <BR>
<DD><FONT size=2> #endif<BR></FONT><BR>
<DD><FONT size=2>Mind you, I have not tried it.<BR></FONT>
<DD><BR>
<DD><FONT size=2>Cheers,<BR>
<DD>Ton<BR></FONT>
<DD><BR>
<DL>
<HR>
<DD><FONT face=Tahoma size=2>From:</B> icc-avr-bounces@imagecraft.com
[<A href="mailto:icc-avr-bounces@imagecraft.com" eudora="autourl">
mailto:icc-avr-bounces@imagecraft.com</A>] On Behalf Of </B>Steven
Lose<BR>
<DD>Sent:</B> donderdag 5 juli 2007 12:59<BR>
<DD>To:</B> Discussion list for ICCAVR and ICCtiny Users. You do NOT
need tosubscribeto icc-announce if you are a member of this.<BR>
<DD>Subject:</B> [Icc-avr] check for adequately nr. of
bits<BR></FONT><BR>
<DD><FONT size=2><A></A>Hi.<BR></FONT><BR>
<DD><FONT size=2><BR></FONT><BR>
<DD><FONT size=2>I want to make the linker check that a variable is
defined big enough, but don’t know how.<BR></FONT><BR>
<DD><FONT size=2><BR></FONT><BR>
<DD><FONT size=2>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.<BR></FONT><BR>
<DD><FONT size=2><BR></FONT><BR>
<DD><FONT size=2>#define NROFFLAGS 17<BR></FONT><BR>
<DD><FONT size=2><BR></FONT><BR>
<DD><FONT size=2>Unsigned int uiFlags;<BR></FONT><BR>
<DD><FONT size=2><BR></FONT><BR>
<DD><FONT size=2>#if NROFFLAGS > NROFBITS(uiFlags)<BR></FONT><BR>
<DD><FONT size=2> ERROR “VALUE TO SMALL”<BR></FONT><BR>
<DD><FONT size=2>#endif<BR></FONT><BR>
<DD><FONT size=2><BR></FONT><BR>
<DD><FONT size=2>Is it possible to do so? (if it had been in code I
would just use (sizeof(uiFlags)*8) )<BR></FONT><BR>
<DD><FONT size=2>And if yes, what is the right way to do
it?<BR></FONT><BR>
<DD><FONT size=2><BR></FONT><BR>
<DD><FONT face="Times New Roman, Times">Med venlig hilsen / Best regards
/ mit freundlichen Grüßen<BR></FONT><BR>
<DD><FONT face="Times New Roman, Times" color=#000080>EC POWER
A/S<BR></B></FONT><BR>
<DD><FONT face="Times New Roman, Times" color=#000080>Steven
Lose<BR></B></FONT><BR>
<DD><FONT face="Times New Roman, Times">Software Ingeniør<BR></FONT><BR>
<DD><FONT face="Times New Roman, Times">Tlf.: +45
87434100<BR></FONT><BR>
<DD><FONT face="Times New Roman, Times">Direkte tlf. +45
58286608<BR></FONT><BR>
<DD><FONT face="Times New Roman, Times">Email: <A
href="blocked::mailto:bsl@ecpower.dk">sl@ecpower.dk</A><BR></FONT><BR>
<DD><FONT face="Times New Roman, Times"><A href="http://www.ecpower.dk/"
eudora="autourl">www.ecpower.dk</A><BR></FONT><BR>
<DD><FONT
face="Times New Roman, Times"><BR></FONT><BR> </DD></DL></DD></DL>_______________________________________________<BR>Icc-avr
mailing list<BR>Icc-avr@imagecraft.com<BR><A
href="http://dragonsgate.net/mailman/listinfo/icc-avr"
eudora="autourl">http://dragonsgate.net/mailman/listinfo/icc-avr</A></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>