Beginner Question - #ifdef -> Where do I define the data the conditional statements are switching on
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2013-11-02 4:56 PM
Posted on November 03, 2013 at 00:56
Hello,
I have been working with the STM8S and STM32F0 Discovery boards. One thing that I see often is the preprocessor directives and macros. One example found in the STM32 discovery demo code is: &sharpifdef DEBUG debug(); &sharpendif I tried to google the topic and I get a lot more information regarding the usage of &sharpifdef and creating macros etc. This is great but nothing quite answered my question. But my question is do I set the DEBUG (or other &sharpifdef) directly in code by using: &sharpdefine DEBUG Or should this be done a different way? I am using IAR and I can go project->options In this window I can go to the Preprocessor tab and there is a box there called defined symbols. Currently it is greyed out unless I choose to ''override inherited settings'' but there is a ''VECT_TAB_FLASH'' in this box. Should I add my &sharpdefines in this box? I get that the &sharpifdef is switching based on defines, but where should I be setting these defines. Is the DEBUG define automatically handled by the IAR IDE and compiler? If it is where would I handle setting switches say for compiling to two different versions of the STM32 chip? For example I have &sharpifdef CHIPONE and &sharpifdef CHIPTWO sections in my code. Do I create two different projects with the same source code but setup the defines in the options box above? Or do I include a project defines file and set all my switches in there using &sharpdefines. #stm32
This discussion is locked. Please start a new topic to ask your question.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2013-11-03 1:01 PM
Posted on November 03, 2013 at 22:01
You seem to be on the right track.
Generally I'll define things within the Pre-Processor settings for global setting, and ST's libraries use these a lot. From makefiles those can come in via -D command line options. Local stuff can either come from #defines in the file, or a related .H
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
