Jump to content

Conditional Compilation Based On Setting Of Target In Ide?

Recommended Posts



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

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






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.

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.

  • Create New...