Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to trim the tokens in Preprocessor directive in C?

Status
Not open for further replies.

Vaughn

Junior Member level 2
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top