main function: argc is negative number RRS feed

  • Question

  • Hi fellow programmers;

    I am writing a cross platform linker using the Microsoft SDK

    but the argc argument is negative. I have written a batch

    script to build the test program which is called main_Test1.bat.

    The following is the batch script:

    cl.exe /c /TC /Gz /MD /w main_Test1.c

    CD ..\objs

    link.exe /SUBSYSTEM:CONSOLE /ENTRY:test_main /OUT:..\tests\main_Test1.exe ..\tests\main_Test1.obj ^

    factory.obj io.obj main.obj util.obj vlid.obj kernel32.lib msvcrt.lib

    CD ..\tests


    The following is the code:

    int test_main(int argc, char *argv[], char *env[]){
     //Variable declarations.
     int ret;
     //Argument checks.
     //Main logic.
     printf("\nargc = %d\n", argc);

    When I build and run the test program, I get a negative number

    for argc.


    Tuesday, October 13, 2020 9:50 PM


All replies