What is the difference between main and mainCRTStartup?Replacing WinMain() with main() function in Win32 programsIssues with C++ command-line arguments on WindowsPremake4 utility and application entry pointQt aplication in Visual Studio - entry pointInterpreting Call Stack output in Visual StudioFailed to compile separated files in Visual Studio (.h , .cpp and main.cpp). ( ERROR: LNK 2001 LNK 2019)Building C++ project on a PC with Windows SDK 7.1 but without VS2010C++ program works on XP SP2 only after installing Visual StudioOpen and Save As Dialog positionCannot uninstall VC++2010: Error: A newer version of Microsoft Visual C++ 2010 Redistributable has been detected on the machineHandling drag and drop files in a running Windows console applicationWinMain entry point - assembly code looks as if there were no arguments passed to entry pointTask could not find “AL.exe” TFS 2013Using “Microsoft Windows Security Auditing” provider in real-time consumer with ETW (Event Tracing for Windows)Why doesn't VCVars.bat find windows.h?How to Set C++ Application Entry Point to main() on Windows using CMake?

Disabling automatic add after resolving git conflict

Anagram Within an Anagram!

Was "I have the farts, again" broadcast from the Moon to the whole world?

Could Sauron have read Tom Bombadil's mind if Tom had held the Palantir?

When is it ok to add filler to a story?

The difference between Rad1 and Rfd1

Pronunciation of "œuf" in "deux œufs kinder" and "bœuf "in "deux bœufs bourguignons" as an exception to silent /f/ in the plural

Generate and graph the Recamán Sequence

How to convert object fill in to fine lines?

Is this the golf ball that Alan Shepard hit on the Moon?

Can you get infinite turns with this 2 card combo?

Professor Roman gives unusual math quiz ahead of

Alphabet completion rate

Do 3D printers really reach 50 micron (0.050mm) accuracy?

Does ultrasonic bath cleaning damage laboratory volumetric glassware calibration?

If protons are the only stable baryons, why do they decay into neutrons in positron emission?

“Transitive verb” + interrupter+ “object”?

A player is constantly pestering me about rules, what do I do as a DM?

How to determine what is the correct level of detail when modelling?

What's the point of DHS warning passengers about Manila airport?

How can I check type T is among parameter pack Ts... in C++?

MH370 blackbox - is it still possible to retrieve data from it?

“Faire” being used to mean “avoir l’air”?

How would a order of Monks that renounce their names communicate effectively?



What is the difference between main and mainCRTStartup?


Replacing WinMain() with main() function in Win32 programsIssues with C++ command-line arguments on WindowsPremake4 utility and application entry pointQt aplication in Visual Studio - entry pointInterpreting Call Stack output in Visual StudioFailed to compile separated files in Visual Studio (.h , .cpp and main.cpp). ( ERROR: LNK 2001 LNK 2019)Building C++ project on a PC with Windows SDK 7.1 but without VS2010C++ program works on XP SP2 only after installing Visual StudioOpen and Save As Dialog positionCannot uninstall VC++2010: Error: A newer version of Microsoft Visual C++ 2010 Redistributable has been detected on the machineHandling drag and drop files in a running Windows console applicationWinMain entry point - assembly code looks as if there were no arguments passed to entry pointTask could not find “AL.exe” TFS 2013Using “Microsoft Windows Security Auditing” provider in real-time consumer with ETW (Event Tracing for Windows)Why doesn't VCVars.bat find windows.h?How to Set C++ Application Entry Point to main() on Windows using CMake?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








9















I'm trying to understand how substituting a different entry point for WinMain works in the Microsoft toolchain.



I already found this question and it was super helpful, but one last detail is nagging at me.



The first time I changed the Linker>Advanced>Entry Point option in Visual Studio, I set it to main by mistake and my program compiled and ran fine. I realized it later and rebuilt the program with it set to mainCRTStartup, as the accepted answer in the linked question suggests, and didn't find anything different.



So, my question is: is there any difference at all between main and mainCRTStartup, and if so, what is the difference?










share|improve this question



















  • 15





    mainCRTStartup basically looks like this: init_tls(); init_crt(); run_global_constructors(); get_args(&argc, &argv); ret = main(argc, argv); run_global_destructors(); exit(ret);. So, main is in there, some place.

    – Damon
    Apr 8 '14 at 11:03

















9















I'm trying to understand how substituting a different entry point for WinMain works in the Microsoft toolchain.



I already found this question and it was super helpful, but one last detail is nagging at me.



The first time I changed the Linker>Advanced>Entry Point option in Visual Studio, I set it to main by mistake and my program compiled and ran fine. I realized it later and rebuilt the program with it set to mainCRTStartup, as the accepted answer in the linked question suggests, and didn't find anything different.



So, my question is: is there any difference at all between main and mainCRTStartup, and if so, what is the difference?










share|improve this question



















  • 15





    mainCRTStartup basically looks like this: init_tls(); init_crt(); run_global_constructors(); get_args(&argc, &argv); ret = main(argc, argv); run_global_destructors(); exit(ret);. So, main is in there, some place.

    – Damon
    Apr 8 '14 at 11:03













9












9








9


5






I'm trying to understand how substituting a different entry point for WinMain works in the Microsoft toolchain.



I already found this question and it was super helpful, but one last detail is nagging at me.



The first time I changed the Linker>Advanced>Entry Point option in Visual Studio, I set it to main by mistake and my program compiled and ran fine. I realized it later and rebuilt the program with it set to mainCRTStartup, as the accepted answer in the linked question suggests, and didn't find anything different.



So, my question is: is there any difference at all between main and mainCRTStartup, and if so, what is the difference?










share|improve this question
















I'm trying to understand how substituting a different entry point for WinMain works in the Microsoft toolchain.



I already found this question and it was super helpful, but one last detail is nagging at me.



The first time I changed the Linker>Advanced>Entry Point option in Visual Studio, I set it to main by mistake and my program compiled and ran fine. I realized it later and rebuilt the program with it set to mainCRTStartup, as the accepted answer in the linked question suggests, and didn't find anything different.



So, my question is: is there any difference at all between main and mainCRTStartup, and if so, what is the difference?







winapi






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 23 '17 at 11:47









Community

11 silver badge




11 silver badge










asked Apr 8 '14 at 10:24









MichaelMichael

4651 gold badge4 silver badges12 bronze badges




4651 gold badge4 silver badges12 bronze badges







  • 15





    mainCRTStartup basically looks like this: init_tls(); init_crt(); run_global_constructors(); get_args(&argc, &argv); ret = main(argc, argv); run_global_destructors(); exit(ret);. So, main is in there, some place.

    – Damon
    Apr 8 '14 at 11:03












  • 15





    mainCRTStartup basically looks like this: init_tls(); init_crt(); run_global_constructors(); get_args(&argc, &argv); ret = main(argc, argv); run_global_destructors(); exit(ret);. So, main is in there, some place.

    – Damon
    Apr 8 '14 at 11:03







15




15





mainCRTStartup basically looks like this: init_tls(); init_crt(); run_global_constructors(); get_args(&argc, &argv); ret = main(argc, argv); run_global_destructors(); exit(ret);. So, main is in there, some place.

– Damon
Apr 8 '14 at 11:03





mainCRTStartup basically looks like this: init_tls(); init_crt(); run_global_constructors(); get_args(&argc, &argv); ret = main(argc, argv); run_global_destructors(); exit(ret);. So, main is in there, some place.

– Damon
Apr 8 '14 at 11:03












2 Answers
2






active

oldest

votes


















17














main() is the entrypoint of your C or C++ program. mainCRTStartup() is the entrypoint of the C runtime library. It initializes the CRT, calls any static initializers that you wrote in your code, then calls your main() function.



Clearly it is essential that both the CRT and your own initialization is performed first. You can suffer from pretty hard to diagnose bugs if that doesn't happen. Maybe you won't, it is a crap-shoot. Something you can test by pasting this code in a small C++ program:



class Foo 
public:
Foo()
std::cout << "init done" << std::endl;

TestInit;


If you change the entrypoint to "main" then you'll see that the constructor never gets called.



This is bad.






share|improve this answer


















  • 2





    As a side note, is there any difference in behavior between C and C++?

    – Michael
    Apr 14 '14 at 7:56


















0














In VS2017,create a console C++ application:



#include "pch.h"
#include <iostream>
int func()

return 1;

int v = func();

int main()





set a breakpoint in main() and begin debug,then the call stack is like:



testCppConsole.exe!main() Line 8 C++
testCppConsole.exe!invoke_main() Line 78 C++
testCppConsole.exe!__scrt_common_main_seh() Line 288 C++
testCppConsole.exe!__scrt_common_main() Line 331 C++
testCppConsole.exe!mainCRTStartup() Line 17 C++
kernel32.dll!@BaseThreadInitThunk@12() Unknown
ntdll.dll!__RtlUserThreadStart() Unknown
ntdll.dll!__RtlUserThreadStart@8() Unknown


So the program entry point is mainCRTStartup,it finally calls the C entry point main(),and the value of v will be 1.



Now set Linker>Advanced>Entry Point to "main" and begin debug,now the call stack is:



> testCppConsole.exe!main() Line 8 C++
kernel32.dll!@BaseThreadInitThunk@12() Unknown
ntdll.dll!__RtlUserThreadStart() Unknown
ntdll.dll!__RtlUserThreadStart@8() Unknown


So main() become the program entry point,and for this time the value of v will be 0,because CRT init functions are not called at all,so func() won't be called.



Now modify the code to :



#include "pch.h"
#include <iostream>

extern "C" int mainCRTStartup();
extern "C" int entry()

return mainCRTStartup();


int func()

return 1;

int v = func();

int main()





and set Linker>Advanced>Entry Point to "entry" and begin debug,now the call stack is:



> testCppConsole.exe!main() Line 14 C++
testCppConsole.exe!invoke_main() Line 78 C++
testCppConsole.exe!__scrt_common_main_seh() Line 288 C++
testCppConsole.exe!__scrt_common_main() Line 331 C++
testCppConsole.exe!mainCRTStartup() Line 17 C++
testCppConsole.exe!entry() Line 10 C++
kernel32.dll!@BaseThreadInitThunk@12() Unknown
ntdll.dll!__RtlUserThreadStart() Unknown
ntdll.dll!__RtlUserThreadStart@8() Unknown


and v will be 1 again.Program entry point is entry(),it calls mainCRTStartup() which call CRT init funtions which calls func() to init v,and mainCRTStartup() finally calls main().






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22934206%2fwhat-is-the-difference-between-main-and-maincrtstartup%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    17














    main() is the entrypoint of your C or C++ program. mainCRTStartup() is the entrypoint of the C runtime library. It initializes the CRT, calls any static initializers that you wrote in your code, then calls your main() function.



    Clearly it is essential that both the CRT and your own initialization is performed first. You can suffer from pretty hard to diagnose bugs if that doesn't happen. Maybe you won't, it is a crap-shoot. Something you can test by pasting this code in a small C++ program:



    class Foo 
    public:
    Foo()
    std::cout << "init done" << std::endl;

    TestInit;


    If you change the entrypoint to "main" then you'll see that the constructor never gets called.



    This is bad.






    share|improve this answer


















    • 2





      As a side note, is there any difference in behavior between C and C++?

      – Michael
      Apr 14 '14 at 7:56















    17














    main() is the entrypoint of your C or C++ program. mainCRTStartup() is the entrypoint of the C runtime library. It initializes the CRT, calls any static initializers that you wrote in your code, then calls your main() function.



    Clearly it is essential that both the CRT and your own initialization is performed first. You can suffer from pretty hard to diagnose bugs if that doesn't happen. Maybe you won't, it is a crap-shoot. Something you can test by pasting this code in a small C++ program:



    class Foo 
    public:
    Foo()
    std::cout << "init done" << std::endl;

    TestInit;


    If you change the entrypoint to "main" then you'll see that the constructor never gets called.



    This is bad.






    share|improve this answer


















    • 2





      As a side note, is there any difference in behavior between C and C++?

      – Michael
      Apr 14 '14 at 7:56













    17












    17








    17







    main() is the entrypoint of your C or C++ program. mainCRTStartup() is the entrypoint of the C runtime library. It initializes the CRT, calls any static initializers that you wrote in your code, then calls your main() function.



    Clearly it is essential that both the CRT and your own initialization is performed first. You can suffer from pretty hard to diagnose bugs if that doesn't happen. Maybe you won't, it is a crap-shoot. Something you can test by pasting this code in a small C++ program:



    class Foo 
    public:
    Foo()
    std::cout << "init done" << std::endl;

    TestInit;


    If you change the entrypoint to "main" then you'll see that the constructor never gets called.



    This is bad.






    share|improve this answer













    main() is the entrypoint of your C or C++ program. mainCRTStartup() is the entrypoint of the C runtime library. It initializes the CRT, calls any static initializers that you wrote in your code, then calls your main() function.



    Clearly it is essential that both the CRT and your own initialization is performed first. You can suffer from pretty hard to diagnose bugs if that doesn't happen. Maybe you won't, it is a crap-shoot. Something you can test by pasting this code in a small C++ program:



    class Foo 
    public:
    Foo()
    std::cout << "init done" << std::endl;

    TestInit;


    If you change the entrypoint to "main" then you'll see that the constructor never gets called.



    This is bad.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Apr 8 '14 at 11:09









    Hans PassantHans Passant

    805k112 gold badges1367 silver badges2148 bronze badges




    805k112 gold badges1367 silver badges2148 bronze badges







    • 2





      As a side note, is there any difference in behavior between C and C++?

      – Michael
      Apr 14 '14 at 7:56












    • 2





      As a side note, is there any difference in behavior between C and C++?

      – Michael
      Apr 14 '14 at 7:56







    2




    2





    As a side note, is there any difference in behavior between C and C++?

    – Michael
    Apr 14 '14 at 7:56





    As a side note, is there any difference in behavior between C and C++?

    – Michael
    Apr 14 '14 at 7:56













    0














    In VS2017,create a console C++ application:



    #include "pch.h"
    #include <iostream>
    int func()

    return 1;

    int v = func();

    int main()





    set a breakpoint in main() and begin debug,then the call stack is like:



    testCppConsole.exe!main() Line 8 C++
    testCppConsole.exe!invoke_main() Line 78 C++
    testCppConsole.exe!__scrt_common_main_seh() Line 288 C++
    testCppConsole.exe!__scrt_common_main() Line 331 C++
    testCppConsole.exe!mainCRTStartup() Line 17 C++
    kernel32.dll!@BaseThreadInitThunk@12() Unknown
    ntdll.dll!__RtlUserThreadStart() Unknown
    ntdll.dll!__RtlUserThreadStart@8() Unknown


    So the program entry point is mainCRTStartup,it finally calls the C entry point main(),and the value of v will be 1.



    Now set Linker>Advanced>Entry Point to "main" and begin debug,now the call stack is:



    > testCppConsole.exe!main() Line 8 C++
    kernel32.dll!@BaseThreadInitThunk@12() Unknown
    ntdll.dll!__RtlUserThreadStart() Unknown
    ntdll.dll!__RtlUserThreadStart@8() Unknown


    So main() become the program entry point,and for this time the value of v will be 0,because CRT init functions are not called at all,so func() won't be called.



    Now modify the code to :



    #include "pch.h"
    #include <iostream>

    extern "C" int mainCRTStartup();
    extern "C" int entry()

    return mainCRTStartup();


    int func()

    return 1;

    int v = func();

    int main()





    and set Linker>Advanced>Entry Point to "entry" and begin debug,now the call stack is:



    > testCppConsole.exe!main() Line 14 C++
    testCppConsole.exe!invoke_main() Line 78 C++
    testCppConsole.exe!__scrt_common_main_seh() Line 288 C++
    testCppConsole.exe!__scrt_common_main() Line 331 C++
    testCppConsole.exe!mainCRTStartup() Line 17 C++
    testCppConsole.exe!entry() Line 10 C++
    kernel32.dll!@BaseThreadInitThunk@12() Unknown
    ntdll.dll!__RtlUserThreadStart() Unknown
    ntdll.dll!__RtlUserThreadStart@8() Unknown


    and v will be 1 again.Program entry point is entry(),it calls mainCRTStartup() which call CRT init funtions which calls func() to init v,and mainCRTStartup() finally calls main().






    share|improve this answer



























      0














      In VS2017,create a console C++ application:



      #include "pch.h"
      #include <iostream>
      int func()

      return 1;

      int v = func();

      int main()





      set a breakpoint in main() and begin debug,then the call stack is like:



      testCppConsole.exe!main() Line 8 C++
      testCppConsole.exe!invoke_main() Line 78 C++
      testCppConsole.exe!__scrt_common_main_seh() Line 288 C++
      testCppConsole.exe!__scrt_common_main() Line 331 C++
      testCppConsole.exe!mainCRTStartup() Line 17 C++
      kernel32.dll!@BaseThreadInitThunk@12() Unknown
      ntdll.dll!__RtlUserThreadStart() Unknown
      ntdll.dll!__RtlUserThreadStart@8() Unknown


      So the program entry point is mainCRTStartup,it finally calls the C entry point main(),and the value of v will be 1.



      Now set Linker>Advanced>Entry Point to "main" and begin debug,now the call stack is:



      > testCppConsole.exe!main() Line 8 C++
      kernel32.dll!@BaseThreadInitThunk@12() Unknown
      ntdll.dll!__RtlUserThreadStart() Unknown
      ntdll.dll!__RtlUserThreadStart@8() Unknown


      So main() become the program entry point,and for this time the value of v will be 0,because CRT init functions are not called at all,so func() won't be called.



      Now modify the code to :



      #include "pch.h"
      #include <iostream>

      extern "C" int mainCRTStartup();
      extern "C" int entry()

      return mainCRTStartup();


      int func()

      return 1;

      int v = func();

      int main()





      and set Linker>Advanced>Entry Point to "entry" and begin debug,now the call stack is:



      > testCppConsole.exe!main() Line 14 C++
      testCppConsole.exe!invoke_main() Line 78 C++
      testCppConsole.exe!__scrt_common_main_seh() Line 288 C++
      testCppConsole.exe!__scrt_common_main() Line 331 C++
      testCppConsole.exe!mainCRTStartup() Line 17 C++
      testCppConsole.exe!entry() Line 10 C++
      kernel32.dll!@BaseThreadInitThunk@12() Unknown
      ntdll.dll!__RtlUserThreadStart() Unknown
      ntdll.dll!__RtlUserThreadStart@8() Unknown


      and v will be 1 again.Program entry point is entry(),it calls mainCRTStartup() which call CRT init funtions which calls func() to init v,and mainCRTStartup() finally calls main().






      share|improve this answer

























        0












        0








        0







        In VS2017,create a console C++ application:



        #include "pch.h"
        #include <iostream>
        int func()

        return 1;

        int v = func();

        int main()





        set a breakpoint in main() and begin debug,then the call stack is like:



        testCppConsole.exe!main() Line 8 C++
        testCppConsole.exe!invoke_main() Line 78 C++
        testCppConsole.exe!__scrt_common_main_seh() Line 288 C++
        testCppConsole.exe!__scrt_common_main() Line 331 C++
        testCppConsole.exe!mainCRTStartup() Line 17 C++
        kernel32.dll!@BaseThreadInitThunk@12() Unknown
        ntdll.dll!__RtlUserThreadStart() Unknown
        ntdll.dll!__RtlUserThreadStart@8() Unknown


        So the program entry point is mainCRTStartup,it finally calls the C entry point main(),and the value of v will be 1.



        Now set Linker>Advanced>Entry Point to "main" and begin debug,now the call stack is:



        > testCppConsole.exe!main() Line 8 C++
        kernel32.dll!@BaseThreadInitThunk@12() Unknown
        ntdll.dll!__RtlUserThreadStart() Unknown
        ntdll.dll!__RtlUserThreadStart@8() Unknown


        So main() become the program entry point,and for this time the value of v will be 0,because CRT init functions are not called at all,so func() won't be called.



        Now modify the code to :



        #include "pch.h"
        #include <iostream>

        extern "C" int mainCRTStartup();
        extern "C" int entry()

        return mainCRTStartup();


        int func()

        return 1;

        int v = func();

        int main()





        and set Linker>Advanced>Entry Point to "entry" and begin debug,now the call stack is:



        > testCppConsole.exe!main() Line 14 C++
        testCppConsole.exe!invoke_main() Line 78 C++
        testCppConsole.exe!__scrt_common_main_seh() Line 288 C++
        testCppConsole.exe!__scrt_common_main() Line 331 C++
        testCppConsole.exe!mainCRTStartup() Line 17 C++
        testCppConsole.exe!entry() Line 10 C++
        kernel32.dll!@BaseThreadInitThunk@12() Unknown
        ntdll.dll!__RtlUserThreadStart() Unknown
        ntdll.dll!__RtlUserThreadStart@8() Unknown


        and v will be 1 again.Program entry point is entry(),it calls mainCRTStartup() which call CRT init funtions which calls func() to init v,and mainCRTStartup() finally calls main().






        share|improve this answer













        In VS2017,create a console C++ application:



        #include "pch.h"
        #include <iostream>
        int func()

        return 1;

        int v = func();

        int main()





        set a breakpoint in main() and begin debug,then the call stack is like:



        testCppConsole.exe!main() Line 8 C++
        testCppConsole.exe!invoke_main() Line 78 C++
        testCppConsole.exe!__scrt_common_main_seh() Line 288 C++
        testCppConsole.exe!__scrt_common_main() Line 331 C++
        testCppConsole.exe!mainCRTStartup() Line 17 C++
        kernel32.dll!@BaseThreadInitThunk@12() Unknown
        ntdll.dll!__RtlUserThreadStart() Unknown
        ntdll.dll!__RtlUserThreadStart@8() Unknown


        So the program entry point is mainCRTStartup,it finally calls the C entry point main(),and the value of v will be 1.



        Now set Linker>Advanced>Entry Point to "main" and begin debug,now the call stack is:



        > testCppConsole.exe!main() Line 8 C++
        kernel32.dll!@BaseThreadInitThunk@12() Unknown
        ntdll.dll!__RtlUserThreadStart() Unknown
        ntdll.dll!__RtlUserThreadStart@8() Unknown


        So main() become the program entry point,and for this time the value of v will be 0,because CRT init functions are not called at all,so func() won't be called.



        Now modify the code to :



        #include "pch.h"
        #include <iostream>

        extern "C" int mainCRTStartup();
        extern "C" int entry()

        return mainCRTStartup();


        int func()

        return 1;

        int v = func();

        int main()





        and set Linker>Advanced>Entry Point to "entry" and begin debug,now the call stack is:



        > testCppConsole.exe!main() Line 14 C++
        testCppConsole.exe!invoke_main() Line 78 C++
        testCppConsole.exe!__scrt_common_main_seh() Line 288 C++
        testCppConsole.exe!__scrt_common_main() Line 331 C++
        testCppConsole.exe!mainCRTStartup() Line 17 C++
        testCppConsole.exe!entry() Line 10 C++
        kernel32.dll!@BaseThreadInitThunk@12() Unknown
        ntdll.dll!__RtlUserThreadStart() Unknown
        ntdll.dll!__RtlUserThreadStart@8() Unknown


        and v will be 1 again.Program entry point is entry(),it calls mainCRTStartup() which call CRT init funtions which calls func() to init v,and mainCRTStartup() finally calls main().







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 11:37









        jw_jw_

        1269 bronze badges




        1269 bronze badges



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22934206%2fwhat-is-the-difference-between-main-and-maincrtstartup%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript