Jump to content
Sign in to follow this  
kenn

Conditional Compilation Based On Setting Of Target In Ide?

Recommended Posts

Hi,

 

I'm interested in developing small applications for PIC models that are supported in the BoostCcompiler, but are not part of the small group of PICs supported by the sourceboost simulator. To date I've been developing in the simulated target then hand-editing the source file for the final target and switching the target selection. It's a pain if I have to go back to simulation to make more changes, then back to the real target, and so on. It would be cool if I could just keep working with one sourcefile, that automatically chooses definitions based on the target.

 

Is it possible to put conditional definition blocks for the different PIC models (containing the different configs, and defining aliases for port names, etc) into one source file, and have the compiler select the right block depending on the target device selected in the IDE?

 

In other words, is some form of the following (pseudocode) possible:

 

if (target==PIC16F877)
  #pragma DATA _CONFIG, ...
  #define INPORT portb
  #define OUTPORT portd
  ...
endif

if (target==PIC16F684)
  #pragma DATA _CONFIG, ...
  #define INPORT porta
  #define OUTPORT portc
  ...
endif

[application]
...

 

 

 

 

I know a bit about conditional declarations in C... I'm just wondering if the IDE compiler target can be used as the test at compile/build time.

 

Thanks for any suggestions.

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×