This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Useless Moves Coding Style

There were a couple of questions regarding coding style in the previous thread.

1) The problem is that I am a strong advocate for the OOP principle of data encapsulation and inheritance. Though C does does support them directly in semantics, you can still use these principles by modifying your style.

In my current design I have a IoPins module, a HardwareInterfaceA module, and a HardwareInterfaceB module. The problem is that the code in BOLD is illegal. Hence my quest for the work arounds. (I could have defined a base class of IoPinsAddress, but I like the idea of encapsulating the type with the address.)

Ideally I would like:

// 'class' IoPins

volatile       IoPins_xOUTC  pdata _at_ 0x68;
volatile const IoPins_xPINSC pdata _at_ 0x78;

// 'class' HardwareInterfaceA : IoPins

#include "IoPins.h"

volatile pdata struct
{
  BYTE          :2;
  BYTE ResetLCD :1;
} IntfA_Pins _at_ IoPins_xOUTC;


// 'class' IntfB : IoPins

#include "IoPins.h"

volatile const pdata struct
{
  BYTE          :1;
  BYTE ResetLCD :1;
} IntfB_xPins _at_ IoPins_xPINSC;


2) My style is to place a volatile and const qualifier where ever it is logically needed.

Even though my code 'may work' by removing the volatile qualifier, I can not be guaranteed that that future versions of improper code and compiler will 'work' together. I am even unnerved that you can not place the const and volatile qualifiers on a sfr's and sbit's.

3) The Keil compiler is exceptional. As with any product, you have to learn to work around it's features. I again thank you for your tips.

0