Page 1 of 1

Testing a CONFIG value at compile time

PostPosted: Sun Dec 03, 2017 8:27 am
by Coccoliso
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.

Re: Testing a CONFIG value at compile time

PostPosted: Sun Dec 03, 2017 12:27 pm
by Jerry Messina
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

Re: Testing a CONFIG value at compile time

PostPosted: Sun Dec 03, 2017 4:50 pm
by Coccoliso
Thanks Jerry I will do this.