Is it possible to set the HEX file name by preprocessor commands?
No.
Since the creation of the Hex file has nothing whatsoever to do with the preprocessor. Nor the compiler. Nor even the Linker.
Take a look at the diagram here, to see how the tools fit together: http://www.keil.com/c51/devproc.asp
The Hex file is created by a standalone utility that converts the output from the Linker into Intel Hex format.
Andy is correct in the fact you cannot directly name the hex file. But you can indirectly name the hex file. Go to options-> output tab. Change the name of the executable to your new name. The executable and the hex file will take the new name. I suggest in the same tab you create an objects folder to collect your executables and hex files in one place. Bradford
But there is the option to run an arbitrary program after a build - so you could use that to re-name the hex file...
I agree for that, But I have to give output file(Executable file) name based on the Macors that i have defined during compilation
is is possible?
The hex file name is defined in the Project properties - so define your macro(s) based on that.
You can use the Key Sequences to extract this information: http://www.keil.com/support/man/docs/uv3/uv3_ut_keysequence.htm
In our code we need to chnage the HEX file name based on the Macro, so is it possible to set the HEX file name based on the Macro condition