Dear Rod,
I don't agree regarding the use of globals. In embedded code you
frequently have to use globals, for example for communication with ISRs.
Also memory bits representing port pins are global, because the port pin
itself is global and almost never shared in a procedural local sense. If
you cant tell what happens to a port pin in your code, you are most
probably not on a good way to efficient embedded programming. I
generally solve the problem of customizing library modules to an
application using make and the preprocessor, because sometimes a
preprocessor #if is required for customization as well to switch on and
off special features which are sometimes required and sometimes not, but
i don't see why declaring port pins as global variables should be a bad
idea.=20
Just in case you say you don't like #if either: i think in embedded
apllications your code should be as simple as possible to simplify
debugging and testing and to safe memory. I prefer to have code which is
not used in an application to be not compiled at all and the
preprocessor is the best (if not only) way to do this properly.
Concerning gotos: I don't think that the designers of the language put
this in just to have a feature that is never used.
Best regards,
Michael
=20
> -----Urspr=FCngliche Nachricht-----
> Von: sdcc-user-admin@...
> [mailto:sdcc-user-admin@...] Im Auftrag von=20
> Rod Boyce
> Gesendet: Montag, 27. Januar 2003 11:00
> An: Royce & Sharal Pereira
> Cc: sdcc-user@...
> Betreff: Re: Fw: [Sdcc-user] Why not global for explicitly=20
> addressed bits?
>=20
>=20
>=20
>=20
> For the life of me I cannot understand why you would want to=20
> do something that while the language may support it, it is=20
> not good programming habits. If you buy a gun and just=20
> because you could shoot your foot off does that mean that you=20
> want to shoot your foot off. Don't get me wrong I'm not=20
> trying to put anybodies ideas down. I have used goto in C=20
> code 3 times in about the last 5 years. I can think up good=20
> justifable reasons to break the rules. BUT I would also say=20
> that the example was very thin I've never liked globals it is=20
> like adding another parameter to every function you write but=20
> that parameter is not included in every prototype for each=20
> function. You can never tell what is happening to a global variable.
>=20
>=20
> Regards,
> Rod=20
>=20
> On Sun, 16 Jul 2000 13:20:31 +0530
> "Royce & Sharal Pereira" <bethell@...> wrote:
>=20
> > Hi,
> > ----- Original Message -----
> > > Your logic for requesting this is flawed. It has been my=20
> experance=20
> > > that
> > each IIC implementation for a new project is diffrent. For=20
> instance=20
> > On one
> > ---------------------------------------------------------------
> > Let me simplify things a bit.
> > My request has nothing to do with IIC implementation...it=20
> was just an
> > example.
> > My point was about C language convention.
> >=20
> > All variables declared outside a function are to be made=20
> global, if=20
> > i'm not mistaken. This is not followed by SDCC in some cases.
> >=20
> > if I say: " bit flg_one ;" outside a function
> > I get: " .globl flg_one" which is correct.
> >=20
> > but if I say "bit at 0x20 flg_one;"
> > I do not get ".global flg_one"
> > while there is basically no difference between the two.=20
> flg_one is not=20
> > declared global in the second case, while it should be. Can someone=20
> > explain why ? I believe that it's just something that's been=20
> > overlooked.
> >=20
> > Whereas, If I say: "char value;" or " data at 0x21 char value;" =20
> > outside a function, both are interpreted correctly & I get=20
> " .global=20
> > _value;" in both cases which is what is expected.
> >=20
> > Thats the point I was trying to make :-). Not about a particular=20
> > function or anything.
> >=20
> > PS: I found a workaround:
> > void globals() _naked
> > {
> > _asm
> > .globl _flg_one
> > .globl _SDA // for example
> > .globl _SCL
> > _endasm;
> > }
> > This gives me the global attribute for explicitly located=20
> bit & sbit=20
> > variables.
> >=20
> > Thanks,
> > --Royce.
> >=20
> >=20
> >=20
> >=20
> >=20
> >=20
> > -------------------------------------------------------
> > This SF.NET email is sponsored by:
> > SourceForge Enterprise Edition + IBM + LinuxWorld =3D=20
> Something 2 See!=20
> > http://www.vasoftware.com=20
> > _______________________________________________
> > Sdcc-user mailing list
> > Sdcc-user@...
> > https://lists.sourceforge.net/lists/listinfo/sdcc-user
> >=20
>=20
>=20
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld =3D Something=20
> 2 See! http://www.vasoftware.com=20
> _______________________________________________
> Sdcc-user mailing list
> Sdcc-user@...
> https://lists.sourceforge.net/lists/listinfo/s> dcc-user
>=20
|