Source code for mainCRTStartup() in Visual C++ - c++

Not sure if I can ask this sort of question here, but I am interested in viewing the source code for mainCRTStartup() in Visual C++.
Did Microsoft made this source code available?

Have a look in %VSINSTALLDIR%VC\crt\src\vcruntime\, where %VSINSTALLDIR% would be something like C:\Program Files (x86)\Microsoft Visual Studio 14.0 for Visual Studio 2015 for example, so different depending on which version you are on, etc. The function you are asking for is in exe_main.cpp
If you are running through the Visual Studio debugger, a good tip is to hit F11, or in the main menu bar go: Debug -> Step Into, that will start debugging and break at the top of main. Then you can just go up the call stack to mainCRTStartup and the it should be able to find the source for you.

Related

Importing a folder into Visual Studio 2017

I am a college student and often I am given project folders for courses with multiple C++ header files, source files, and a makefile usually. I am using Visual Studio 2017 for reference.
Visual studio is my favorite IDE for debugging but I do not know how to integrate one of these folders into Visual Studio so I might debug from the application and not from a terminal. I am wondering if someones knows a way for me to open this folder in VS, and run/debug it like a normal console application? I realize the makefile might add an additional layer of complexity.
This is an image of the contents of a folder I want to be able to run/debug/execute normally in visual studio
I can open this folder in visual studio by right clicking -> open in visual studio.
However when in visual studio, I cannot build, run, debug or anything. Visual studio is acting more like a text editor than an actual IDE. I would like to be able to build/make my program through visual studio so I can launch/debug it in visual studio.

Debugging C++ app in Visual Studio 2017 steps into not my code is there a way to turn this off?

Ok so when debugging, for example when i set my breakpoint on simple string declaration
string a;
and then pressing f11 (step into) my debugger steps into xstring file, and i don't want it. I want it to step into JUST MY code, it works fine with C# tho.
[C++] https://i.imgur.com/qvPfnwF.png
[C# and what i want it to be in C++ also] https://i.imgur.com/j3SAgJr.png
I have "Just My Code" enabled and i don't know what to do. I just dont want it to step in not my files.
The C# feature you are referring to is called "Just My Code". Unfortunately, Visual Studio does not implement it in the same way for C++. As documentation says:
C++ Just My Code is different than .NET Framework and JavaScript Just
My Code because the stepping behavior is independent of the call stack
behavior.
There is a workaround, however:
You can create your own .natstepfilter and .natjmc to customize the
stepping and call stack window behavior in the %USERPROFILE%\My Documents\Visual Studio 2015\Visualizers.
Despite of the typo in the documentation ("2015") and the horribly convoluted way this was designed, the trick actually works!
For example, with the Visual Studio 2017 installation on my machine, I can go to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Packages\Debugger\Visualizers and a add file called .natstepfilter with the following content:
<?xml version="1.0" encoding="utf-8"?>
<StepFilter xmlns="http://schemas.microsoft.com/vstudio/debugger/natstepfilter/2010">
<Function>
<Name>std::.*</Name>
<Action>NoStepInto</Action>
</Function>
</StepFilter>
Now when I debug in Visual Studio and step into something, all C++ standard-library functions are skipped.
Note that the actual format of the XML file is not validated very strictly by Visual Studio. I've actually used the simpler form explained in the Visual Studio 2015 documentation.

How to run Code Analysis on x64 Project in Visual C++?

I am trying to run the code analysis of Visual Studio 2015 on my x64 VC++ project. However I get the following error:
Error C1250 Unable to load plug-in 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\\bin\localespc.dll'
I am activating the x64 toolset of Visual Studio by running the batch script "vcvarsall.bat amd64" before I start the IDE. Visual Studio is run with the "/useenv" option afterwards.
When I check the VC++ environment variables, I can see that the following path is contained in the PATH variable:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64
How can I tell Visual Studio to use the code analyzer (localespc.dll) from there and not the x86 version which it apparently tries to use (according to the error message).
Thanks a lot for your help!
I was having the same issue with my 64-bit C++ projects. I discovered simply renaming/removing localespc.dll from VC\bin allowed the Code Analysis builds to succeed and still report analysis warnings. It seems if VS doesn't find this dll in the VC\bin directory then it won't add the compiler switch for /analyze:plugin but otherwise passes all the other switches required by the Code Analysis.
Set the following property in your project file: <PreferredToolArchitecture>x64</PreferredToolArchitecture>
This tells Visual Studio to use the 64-bit version of various tools, including code analysis. I found How to make Visual Studio use the native amd64 toolchain helpful on the topic.
Note that renaming localespc.dll no longer solves the problem with Visual Studio 2017. It seems that setting PreferredToolArchitecture is Microsoft's intended way to do this.

C++, Visual Studio Disassembly Not Availble

I'm trying to view the disassembly of my code as explained in the article below:
How to view the assembly behind the code using Visual C++?
But I can't seem to find the disassmebly option:
Any help on this issue would be most appreciated.
Additional Notes: It is a win32 debug project in C++.
I use MS Visual Studio 2012 and I see option "Go to disassembly" when debugging code. I suppose that such features can depend on Visual Studio edition. So see your version and refer to http://www.visualstudio.com/en-us/products/compare-visual-studio-products-vs.aspx
Also, maybe some options of IDE switch this option, see http://http.developer.nvidia.com/NsightVisualStudio/3.2/Documentation/UserGuide/HTML/Content/PTX_SASS_Assembly_Debugging.htm

How to move a project from Visual Studio 2005 to Visual Studio 2012

I want to move my C++ project to Visual Studio 2012; I solved problems and can build and create the exe. But an error, msvcp80d.dll missing happens. I think that's a Visual Studio 2005 dll so I want to remove the dependency on that and get past the error. How can I do that?
Fastest way is to search your intermediate build folder for string msvcp80d.dll to see which file picks it up. If all, then look in your .vcxproj file and the .props files it imports.
If it's not found at all then you have an indirect tie, use depends.exe on your executable to see which other dll depends on this one. (You may do it right at start.)