Now set the default value for the compile command line. Add the following to your init file:
;; Set up for Visual C++ compiling (setq compile-command "nmake -f ")
If you work on the same project long term, you can add the project makefile to the string.
David Biesack suggests that perhaps it's easy to write a Makefile in the project directory which does
PROJECT=MyProject all: debug debug: FORCE nmake /f $(PROJECT).mak CFG="$(PROJECT) - Win32 Debug" release: FORCE nmake /f $(PROJECT).mak CFG="$(PROJECT) - Win32 Release" FORCE:
and then you can simply change compile-command to nmake.
Caleb T. Deupree reports that on VC++ 5.0 and up, "You can also set an option in Options/Build to export a makefile every time the project is saved, which you can then use to compile with ‘nmake -f project.mak’." VC++ 4.0 builds the make file every time, and there is no option.