Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/05/05 19:29
Read: times


 
#103325 - #define -- using ##
Hello All,

Was thinking if there any other method in implmenting the below requirement...

well there are 2 files, main.h and main.c

main.h file can changed by the end user. He can define a port for a device, see below

#define LCD_DATA_PORT P0

In main.c file (will become a library file later). This LCD_PORT will be used bytye wise and also as bit wise.

so in the main.c file the implementation is as below:

#include "main.h"

#define LCD_PBIT(a,b) a##_##b
#define LCD_DATA_PORT_BIT(x,y) LCD_PBIT(x,y)
#define LCD_DATA_PORT_0 LCD_DATA_PORT_BIT(LCD_DATA_PORT, 0)

void main()
{
int i;

while(1)
{
for(i=0;i<=10;i++)
{
LCD_DATA_PORT = i; /* byte access */

LCD_DATA_PORT_0 = 0; /* bit access */

}
}
}

I feel, the above implementation is ok or is there any better method???

The whole intention is that if the user changes the port setting in the .h file then this change reflect in .c file for both bit and byte access.

OT:
Anyone from Melbourne in this forum??? Can you please mail me.

Regards,
Raj Shetgar

List of 2 messages in thread
TopicAuthorDate
#define -- using ##            01/01/70 00:00      
   Is it effective on .obj or .lib?            01/01/70 00:00      

Back to Subject List