batch file - Compile c code using gcc without installing mingW/cygwin -
i have visual studio installed in system. corresponding compiler , environment variables set. when try compile c file using cl command, works fine. zipped mingw system , extracted system. have in d:/mingw. have created batch file compiling c file. contents of batch file are,
set gccpath=d:/mingw/bin %gccpath%/gcc.exe -c -std=c99 -o myc.o ../myc.c -i..\.
when run batch file, producing few errors. 1 such error
stdio.h:209:71: error: macro "snprintf" requires 5 arguments, 4 given
the above error might due fact compiler takes stdio.h of visual studio instead of mingw's default header file. error is,
error: previous declaration of 'xxxxfun' here
what should change in batch script compile c file using mingw. compilation process successful when use visual studio, throws error if use gcc same set of files
edit: fixed latter error. first error doesn't occur when stdio.h included @ first. if include stdio.h @ middle of include section, error comes.
#include <string.h> #include <assert.h> #include <minmax.h> #include "myfunctions.h" #include "mymodule.h" #include <stdio.h>
when have stdio.h @ last shown, error coming. if move line #include <stdio.h>
other lines above #include <mymodule.h>
, specified error not coming. reason behind strange behavior?
check whether defining snprintf using macros in of header files. error may caused due incorrect/unnecessary macro.
wiki
Comments
Post a Comment