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.
I'd like to have a Windows environment variable like MYINCDIR=c:\myincdir that specifies the root of a set of include directories and then use that variable within the -I command-line option of the compiler. I've tried these without success:
-I%MYINCDIR%\foo -I"%MYINCDIR%\foo" -I"%MYINCDIR%"\foo
to no avail.
Is there any way to pick up an environment variable into the -I option?
Thanks, Andrew
You're leaving the crucial aspect of the problem out of the picture. That would be the tool you're using to call the compiler.
It's that tool's job to expand environment variables, and it depends entirely on that tool how it's done. %MYINCDIR% would work in a Windows batch file (*.bat or *.cmd). Most Makefiles would use $(MYINCDIR), Unix-type shell scripts would use $MYINCDIR or ${MYINCDIR}, and IDEs use whatever they damn well please --- or they don't offer this feature at all.
I'm trying to use this from uVision 4.10. In the C/C++ tab of the "Target Options" dialog I modify the "Include Paths" entry and can see that the "Compiler control string" has the needed -I options.
I was hoping that the shell spawned by uVision would expand the variables for me. I'll do some experiments on the command line to see what works.
I'll probably end up using a makefile so I don't have to battle the IDE...
I was hoping that the shell spawned by uVision
I rather much doubt that uVision spawns any shell at all. I never used uV 4.1 myself, but the versions I did use seemed to run the compiler directly.
I don't think uVision supports Environment Variables.
The nearest thing, I thinkg, is its Key Sequences: http://www.keil.com/support/man/docs/uv4/uv4_ut_keysequence.htm - maybe that can serve your purpose?
Thanks for the tip about the key sequences. Even though I don't see a way to use those to solve the include path problem it's good to know they exist.
Andrew