How to trim the tokens in Preprocessor directive in C?

Status
Not open for further replies.

Vaughn

Junior Member level 2
Joined
Feb 8, 2013
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
India
Activity points
1,520
Normally we use "##" (token pasting operator) to concatenate the tokens in preprocessor directives like:


Code C - [expand]
1
2
3
#define SET_LOW(BIT)    PORT(BIT ## _PORT) &= ~(1<<BIT)
#define LED         PC0
#define LED_PORT        PORTC



So my question is: Are there any method in C (especially in preprocessor directives) to extract just the letter "C" from "PC0" or trim the letter "P" and "0" (from code line 2nd) so that we could use it that letter in code line 1 to avoid the complication of Code line 3?
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…