This is the batch file I am using to compile c/c++ code with VS 12 (aka Visual Studio Express 2013)
There was an update to C99 for "c" source although I primarily test with c++11 code.
I have not really beat on it as my distros of choice are TDM-GCC or NUWEN
James
Parameters:
VS2013.BAT SoureFileName(no extension) [-m32 or -m64] [ con gui dll obj] [release or debug]
The release debug is optional and will default to release
@setlocal
@ECHO OFF
REM Note that this bat will compile either .cpp or .c sources.
REM it checks for .cpp first and if you happen to have a .cpp file even though you want
REM .c the .cpp will be used. Delete a .cpp before you translate to a .c source
REM get just file name. RadAsm3 passes complete path with non project files
REM Note: because FN is set using %F% with quotes no need for quoted %FN%
REM ----------------------------
SET F=%~nx1
REM ----------------------------
REM See if we have a .cpp or a .c source
IF EXIST "%F%.cpp" (
SET FN="%F%.cpp"
SET CFIX=0
GOTO start
)
REM NO .cpp? check for a .c
IF NOT EXIST "%F%.c" GOTO usage
SET FN="%F%.c"
REM For use with InsertOptArg below (bc9Basic)
SET CFIX=1
:start
IF [%2]==[] GOTO usage
IF [%3]==[] GOTO usage
REM param 4 -> Debug or Release
SET BUILD=%4
IF [%BUILD%]==[] SET BUILD=Release
IF /I [%2] == [-m32] (
SET XTYPE=x86
GOTO gotit
)
IF /I [%2] == [-m64] (
SET XTYPE=x86_amd64
)
:gotit
REM do the setup for paths and 32/64
CALL "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" %XTYPE%
IF /I [%3] == [CON] (
SET SUBSYS= /SUBSYSTEM:CONSOLE
SET FTYPE="Windows Console App"
)
IF /I [%3] == [GUI] (
SET SUBSYS=/SUBSYSTEM:WINDOWS
SET FTYPE="Windows Gui App"
)
IF /I [%3] == [DLL] (
SET SUBSYS=/DLL
SET FTYPE="a Windows DLL"
)
IF /I [%3] == [OBJ] (
SET SUBSYS=/DLL
SET FTYPE="a Windows Object File"
)
REM --------------------------------------------------------------
REM always use the %F%.rc file in the Res Directory if it exists
REM this should handle both projects and individual files with resources
IF EXIST "res\%F%.rc" (
ECHO Compiling resources.....
cd res
Rc "%F%"
SET VRES="res\%F%.res"
cd ..
) ELSE (
IF EXIST "%F%.rc" (
ECHO Compiling resources.....
Rc "%F%"
SET VRES="%F%.res"
)
)
REM For use with bc9Basic
REM Insert optional arguments for "c" source
REM IF [%CFIX%]==[1] InsertOptArg %FN% -vc
REM --------------------------------------------------------------
ECHO Compiling %FN% To %FTYPE%
REM the first compile/link creates a .def file which we use in a
REM second call to add undecorated function names to the dll.
IF /I [%3]==[DLL] (
cl.exe %FN% %VRES% /EHsc /MT /link /DLL /OUT:"%F%.dll"
REM add undecorated function names to the dll only on 32 bit
IF /I [%XTYPE%]==[x86] (
IF EXIST "%F%.def" (
cl.exe /LD "%F%.obj" %VRES% "%F%.def"
)
)
GOTO cleanup
)
IF /I [%3]==[OBJ] (
cl.exe /c /O1 /Gd /W1 /EHsc /MT %FN% %WIN_VER% %5 %6 %7 %8
GOTO cleanup
)
REM Console and gui
cl.exe /O1 /Gd /W1 /EHsc /MT %FN% /Fe"%F%.EXE" %WIN_VER% %VRES% %SUBSYSTEM% %5 %6 %7 %8
:cleanup
ECHO Finished!
IF /I NOT [%3]==[OBJ] (
IF EXIST "%F%.obj" del "%F%.obj"
)
IF EXIST "%F%.res" del "%F%.res"
GOTO done
:usage
ECHO **************************************************************
ECHO Usage: VS2013.BAT MainFile [-m32 -m64] [con gui dll obj] extra files
ECHO Note: ExtraFiles can be .libs, .res , .obj
ECHO **************************************************************
:done
endlocal