We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello, Keil uVision world! :)
Keil uVision project file contains some target's settings, stored as e.g. Device (C8051F340) or DevID (3997). How to use these values in the source text (e.g. for conditionally translation)?
For example:
#if DevID==3997 ... #endif
or
$if (DevID==3997) ... $endif
Cpt. Vince, thank you for detailed info.
Cpt. Vince wrote: Since the Keil tool doesn't have a predefined constant ... you can create it yourself. ... Each compile configuration uses a target profile...
Here you can define Project Targets, Groups, and the files for your project. You can have several different target groups using different target processors... I use target setings in all my projects. ;)
Cpt. Vince wrote: Under the Keil's IDE Options for Target "C51" Tab you can predefine constants...
Beacuse of developpment and support many similar projects (in fact, they are "derived" from a few of "roots") differing on miscellaneous functions, I found inconvenient to introduce and check a lot of settings (the same for C and ASM!). Especial for libraries developpment. Therefore my projects have now only one constant defined via IDE: CPU type. :)
Using of the Keil Configuration Wizard - like "GUI settings dialog" - is more comfortable. IMHO.
Cpt. Vince wrote: As a general rule though, I don't like IDE specific settings and prefer to control the build process as much as I can within the "controlled source [code]" itself. By having an include file that specifies the processor target, you can define it there as you would normally do anyway...
CPU type is already defined via Keil IDE - why don't use this?
Cpt. Vince wrote: If you have source code that depends upon your specific IDE like (Keil's tool suite), then you are limiting yourself and code when/if your company changes over to IAR's tools, or BSO Tasking, etc. ...
Sure. But I can define "manually" the same constants, #defines etc. by using other tools too - without loss of compatibility. Or nearly without...
Language extensions (e.g., using C-Preprocessor directives in ASM source code) could cause more problems by code porting. But these extensions are comfortable! Schould one not use they and stay in 197..? ;)
So every developper find own way, own style etc. IMHO.
P.S. Sorry for my english...
The answer from Keil:
currently this information cannot be directly accessed by the Compiler/Assembler. It is indented to be used by programming utilities and the help systems (by querying the environment variables).