Sysprogs forums › Forums › VisualGDB › MSBuild, Preprocessor and User Variables
- This topic has 4 replies, 2 voices, and was last updated 4 years, 6 months ago by support.
-
AuthorPosts
-
May 7, 2020 at 15:06 #28076koistoParticipant
I have configured my embedded project to use MSBuild and I wish to pass a value set in User Variables into my code using a pre-processor macro.
I have defined the User Variable (for all users) as follows:
FOOSTR = 123456
and checked the option to propagate this to the build environment.
Within VisualGDB Project Properties, MSBuild Settings, Preprocessor Macros I have defined the following:
FOO=”\”$(FOOSTR)”\”
Which I would expect to be expected to be expanded as follows on the command line to gcc:
-DFOO=”123456″
However in my code FOO expands to an empty string.
Any help would be appreciated.
May 7, 2020 at 15:44 #28077supportKeymasterHi,
Normally this should work. Please make sure you restarted VS from the Start menu (not from another program) after defining the new environment variable, as the environment is not immediately applied to all existing processes.
If it doesn’t help, please check the .vcxproj file and the .rsp files (you can read more about the .rsp files here) for the definition of the macro and also double-check it with running “echo %FOOSTR%” from Command Prompt.
If nothing helps, please share the contents of the .rsp file, the .vcxproj file and the output from echo %FOOSTR% and we can recheck for common issues.
May 7, 2020 at 16:38 #28084koistoParticipantHi,
Thank you for your quick reply. I have attached the appropriate files and screen shots.
Attachments:
You must be logged in to view attached files.May 7, 2020 at 16:39 #28088koistoParticipantI was unable to upload the .rsp file. I have pasted the contents of main.gcc.rsp here:
<span>-mthumb -mcpu=cortex-m3 -I../../CubeMx/Inc -I../../CubeMx/Drivers/CMSIS/Device/ST/STM32F1xx/Include -I../../CubeMx/Drivers/STM32F1xx_HAL_Driver/Inc -I../../CubeMx/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I../../CubeMx/Drivers/STM32F1xx_HAL_Driver/Src -I../../CubeMx/Drivers/CMSIS/Include -IC:/Users/JAshby/Desktop/FooExample/fooExample_sol/fooExample/ -ggdb -O0 -DARM_MATH_CM3 -Dflash_layout -DSTM32F103RB -Dflash_layout -DSTM32F103xB ‘-DFOO=”\””\”‘ -DDEBUG=1 -DDEBUG=1 -ffunction-sections -fdata-sections -c “C:/Users/JAshby/Desktop/FooExample/CubeMx/Src/main.c” -o “VisualGDB/Debug/main.o” -MD -MP -MF “VisualGDB/Debug/main.dep”</span>
May 11, 2020 at 22:01 #28106supportKeymasterThanks for sharing the detailed screenshots. Indeed, MSBuild would normally expand the MSBuild-level variables and the environment variables, but not VisualGDB-specific variables.
Please try this build: VisualGDB-5.5.5.3610.msi
Then open VisualGDB Project Properties -> User Variables and ensure that the variables you want to use from MSBuild have the “propagate to the environment” flag set. If it is already set, change any variable value and press “Apply” to force VisualGDB to rebuild the property files. This will generate a $(ProjectName)-user.props file in the project directory, that will list the variables exported to MSBuild.
VisualGDB will automatically include that file when building the project, letting you reference those variables across the MSBuild settings.
Let us know if you have any feedback about the new feature and we will be happy to make it even better.
-
AuthorPosts
- You must be logged in to reply to this topic.