Conditionals in .prm file

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Conditionals in .prm file

Jump to solution
2,579 Views
sebasira
Senior Contributor I

I just wanted to know if there is a way to make a condition inside .prm file, such as #ifdef or something like that.

 

The idea is to merge a project with the bootloader, using the HEXFILE sentence, and the conditional would be used to compile with or without it

 

Best regards!

Labels (1)
Tags (1)
0 Kudos
1 Solution
1,198 Views
BlackNight
NXP Employee
NXP Employee

Hello,

the answer depends if your are using the classic CodeWarrior or the eclipse one.

In classic you find that option in the linker preference panel as "Preprocess PRM file".

 

Extract from the manual:

Preprocess PRM file: When checked, the preprocessor of the ANSI-C compiler is
used to preprocess the PRM file prior to the linking step. In the PRM file, all ANSI-
preprocessor conditions like conditional inclusion (#if) are available. The same
preprocessor macros as in ANSI-C code can be used (e.g., #ifdef __SMALL__).

 

BK

View solution in original post

0 Kudos
8 Replies
1,199 Views
BlackNight
NXP Employee
NXP Employee

Hello,

the answer depends if your are using the classic CodeWarrior or the eclipse one.

In classic you find that option in the linker preference panel as "Preprocess PRM file".

 

Extract from the manual:

Preprocess PRM file: When checked, the preprocessor of the ANSI-C compiler is
used to preprocess the PRM file prior to the linking step. In the PRM file, all ANSI-
preprocessor conditions like conditional inclusion (#if) are available. The same
preprocessor macros as in ANSI-C code can be used (e.g., #ifdef __SMALL__).

 

BK

0 Kudos
1,198 Views
Allem77
Contributor I

Hello BlacKnight,



I encountered the following problem, maybe you can help me.



I set the "Preprocess PRM file" option as you said (btw without this option and without conditionals in the prm file, I get no errors during make).



I use the MemoryBanker tool which is generating a .pre.prm file. All the errors that I get are located inside this file and are linked to each "#pragma" instruction. Even without any conditionals in the .prm file I get those errors when the "Preprocess PRM file" option is set. You will find more information in the attachments...



Thank you for your time.



Allem77.

0 Kudos
1,198 Views
sebasira
Senior Contributor I

Hi Allem77!

 

I've never used #pragma's in prm pre-processesing. Looking at your warning and error image, I can suggest two things:

 

1) "Preprocessor failure because of not supported preprocessor directive", perhaps pragma is not suported

 

2) "Preprocessor failure because of Expected # at line start", maybe you should erase indet and put the #pragma at the begining of the line (column 0)

 

0 Kudos
1,198 Views
Allem77
Contributor I
Hi Sebastian, I got in contact with the CW developers and indeed there is a compatibility problem. I'm posting their answer below... Have a nice day, Allem77. From Dev team: ************************ There is a compatibility problem (though not documented). With MemoryBanker enabled, a few peculiar header files (either provided with the library or linker-generated) need to be automatically included via the -AddIncl compiler option. Given the example you provided (test.mcp), this is what the compiler command line looks like: - for target 'Pass1': -CpuHCS12XE -Ml -D__NO_FLOAT__ -MapFLASH -D__MAP_FLASH__ -AddIncldistribution_support.h -MemBanker -D_DISTRIBUTE_CODE -D_DISTRIBUTE_CONST -D_DISTRIBUTE_DATA - for target 'Standard': -CpuHCS12XE -Ml -D__NO_FLOAT__ -MapFLASH -D__MAP_FLASH__ -AddIncl__MB_code.h -AddIncl__MB_data.h File distribution_support.h is provided with the HC(S)12 library. It contains the CODE_SEG/DATA_SEG pragmas required for activating code/data distribution. If it were not automatically included, it would have to be explicitly included in each source file within the application (obviously, only for the first compile-link pass). Files __MB_code.h and __MB_data.h are generated by the linker during the first pass. They contain the code/data distribution optimization information (provided via CODE_SEG/DATA_SEG pragmas) that the compiler needs to use in the second pass. As with distribution_support.h, if these files were not automatically included, they would have to be included in each source file (obviously, only for the second compile-link pass). When PRM file preprocessing is enabled, the compiler-embedded preprocessor will be instructed to preprocess the PRM file as if it were a C source file. The linker will then use (as linker parameter file) the preprocessing output (i.e. .pre.prm, not .prm). On the other hand, the -AddIncl options (for including the above-mentioned header files) directly affect the compiler-embedded preprocessor: it will include the header files prior to preprocessing the PRM file, just like it would do for any other source file to be preprocessed. Therefore, CODE_SEG and DATA_SEG pragmas will make it into the PRM preprocessor output - that the linker will subsequently use. The linker cannot handle CODE_SEG and DATA_SEG pragmas, hence the problem.
0 Kudos
1,198 Views
Allem77
Contributor I

Hi Sebastian,

 

thank you for the hints.

Actually the #pragma's are coming from the MemoryBanker tool when it is optimizing the location of the different functions in the banks. So I don't have any control about the generation of those #pragma's.

 

It seems that the MemoryBanker tool is not compatible with the .prm perprocessing possibility...  hmmm

0 Kudos
1,198 Views
sebasira
Senior Contributor I

Hi BlackNight, thanks for you inmediate response!

 

I forgot to specify that, II'm using CW v3.1; so yes, it's the classic one.

But I don't have that option :smileysad:

 

In CW 4.6 is there, but no in CW 3.1.... Is there anything I can do under CW 3.1? Update linker or use linker from CW 4.6?

0 Kudos
1,198 Views
BlackNight
NXP Employee
NXP Employee

Hello,

this option is a feature of the IDE, so you would need to upgrade to that IDE/CW version.

But if you want to use the build tools from 3.1, then technically this should be possible: use the prog and lib folders from 3.1 inside the 4.6 IDE.

 

BK

0 Kudos
1,198 Views
sebasira
Senior Contributor I

Thanks again!

 

I've migrated my proect from CW 3.1 to 4.6 so I can compile with v4.6

0 Kudos