How to define a preprocessor Marco in ModusToolbox 2.2

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Oxanagig3
Level 2
Level 2
5 replies posted 5 questions asked 5 sign-ins

Hello,

There is a big chance from ModusToolBox v1 to 2.2, where the project configuration is very different. 

One thing I am struggling with is how to define a macro in the project configuration, there is a dedicated section in the V1.1. 

I have tried Preprocessor Include Paths, Maros etc.. section in the project properties, I have used the CDT User Setting Entries, but it doesn't work.

 

-Xiang

0 Likes
1 Solution

Hello,

You can control the build flow of the application using only the Makefile. Do not make use of Eclipse IDE options, they won't work. 

In the Makefile, to define macros, you can make use of the DEFINES variable in this manner:

# Add additional defines to the build process (without a leading -D).
DEFINES=DFU

For more information on the different Makefile variables, please refer to the ModusToolbox User Guide

Regards,
Dheeraj

View solution in original post

4 Replies
DheerajPK_41
Moderator
Moderator
Moderator
750 replies posted 500 likes received 500 replies posted

Hi,

I guess the main difference you will be able to see is the makefile, Configurations, etc.  Each application will be having a makefile, which controls the project creation and build processes. Please refer below blog to understand how to manage makefile in an application.

https://community.cypress.com/t5/Knowledge-Base-Articles/Managing-the-Makefile-for-ModusToolbox-v2-x...

 

General pre-processors and macros are defined in the application source code itself.  Build configurations, component inclusions, etc. have to be defined in the makefile.

 

"Here is a dedicated section in the V1.1" -> Could you please share screenshot of it? I don't exactly remember what was the dedicated section in v1.1.

 

Thanks,

-Dheeraj

0 Likes

Hello,

This is what I wanted to do:

I have a project that is going to be a DFU app, and I have configured two build profiles, one is building it as a standalone for debugging purposes, and the other is as a DFU image. 

so in the main file, there is a line of code only for DFU build profile.

XiGa_1309021_0-1610751759844.png

 

I wanted to use DFU as a preprocessor macro to determine if the line is included for the build or not.

I did set it in the profile configuration as shown below:

XiGa_1309021_1-1610751932905.png

However,  it doesn't work. The line under the DFU macro was not included while using this build profile.

 

 

0 Likes

Hello,

You can control the build flow of the application using only the Makefile. Do not make use of Eclipse IDE options, they won't work. 

In the Makefile, to define macros, you can make use of the DEFINES variable in this manner:

# Add additional defines to the build process (without a leading -D).
DEFINES=DFU

For more information on the different Makefile variables, please refer to the ModusToolbox User Guide

Regards,
Dheeraj

Thanks. it works as expected.

0 Likes