Page 1 of 1

Variable names

Posted: 01 Jul 2014 08:21
by ilferrari
The compiler claims lots of commonly-used variable names, such as

Identifier "a" has been already declared in "P18F26J50.mbas"
Identifier "c" has been already declared in "P18F26J50.mbas"
Identifier "p" has been already declared in "P18F26J50.mbas"
Identifier "s" has been already declared in "P18F26J50.mbas"
Identifier "p1" has been already declared in "P18F26J50.mbas"
Identifier "s1" has been already declared in "P18F26J50.mbas"
Identifier "b1" has been already declared in "P18F26J50.mbas"

The compiler should leave these to the developer.

Re: Variable names

Posted: 25 Jul 2014 08:42
by filip
Hi,

These identifiers are declared in the definition file of the MCU and user should modify the code in respect to that.

Regards,
Filip.

Re: Variable names

Posted: 25 Jul 2014 15:53
by janni
ilferrari wrote:The compiler claims lots of commonly-used variable names, such as...
It's Microchip that uses these names for specific registers/bits of a processor, not the compiler. You're free to rename them (if you intend to use only your own libraries, that is :wink: ).

Note that 8-bit processors are not computers with operating system separating programmer from hardware. One has to use processor resources directly, and as best (and only) information about specific processor is contained in it's datasheet, it makes sense to use the original naming defined therein.

In one detail you are right, though. The b0..b7 names are needed only in mC where one cannot use simple numbers to designate bits. In mB and mP it made little sense to introduce them, but mE probably wanted to have processor definitions in all compilers alike.

On the other hand, good programming practice discourages use of simple, one or two letter names (except for indices, perhaps) - after all text editors nowadays are not limited by small memory :) .