Testing a CONFIG value at compile time

General questions about Firewing...

Testing a CONFIG value at compile time

Postby Coccoliso » Sun Dec 03, 2017 8:27 am

Hi,

Is there a way to verify the value of a CONFIG parameter at compile time?

Example:

Config CANMX = PORTC // ECAN TX and RX pins are located on RC6 and RC7, respectively
Config CANMX = PORTB // ECAN TX and RX pins are located on RB2 and RB3, respectively

#if "Config CANMX = PORTC" // with what syntax ??
' add this constants
#else
' add this constants
#endif

Thank you all.
User avatar
Coccoliso
 
Posts: 177
Joined: Sat Sep 27, 2014 10:02 am

Re: Testing a CONFIG value at compile time

Postby Jerry Messina » Sun Dec 03, 2017 12:27 pm

I don't think so. See viewtopic.php?f=7&t=172&p=993&hilit=isconfig#p993

What I've done in the past is to turn the config selection into a #option and then test that...
Code: Select all
// for a config selection
//    CANMX(CANMX) = [PORTC, PORTB]

// create a new option to hold the config setting
#option CAN_MX = PORTC

// set the config using the option value
config CANMX = CAN_MX

// test the option, not the config
#if (CAN_MX = PORTB)
  #warning "using PORTB"
#elseif (CAN_MX = PORTC)
  #warning "using PORTC"
#else
  #error "unknown"
#endif
Jerry Messina
 
Posts: 280
Joined: Thu Feb 14, 2013 10:16 am

Re: Testing a CONFIG value at compile time

Postby Coccoliso » Sun Dec 03, 2017 4:50 pm

Thanks Jerry I will do this.
User avatar
Coccoliso
 
Posts: 177
Joined: Sat Sep 27, 2014 10:02 am


Return to Questions

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x