I have a Class for an ADT which is organized into a .h header file and .cpp implementation file.
I'm attempting to test the class and I need the debugger to step into one of the class functions inside the .cpp implementation file. However, whenever I press step into the debugger just jumps over the function. I've tried to look for solutions but only find them from Visual Studio. Keep in mind that I am using Visual Studio Code! turning off "just my code" is not an option for me.
How can I make the debugger step into the functions inside my .h/.cpp files for my class? Thanks!
Question has been resolved in the comments. Since I have a lengthy makeFile, I forgot to add the debugging option when compiling my ADT files.
Related
I am working on an OpenGL game in C++ and am using Visual Studio 2013 for it. Until now everything worked fine but since about 3 days, one of my files is no longer compiled when I change it. The strange thing is, it is really just related to this one single file. Every other file works as expected. So if I change something in said file (it is a .h file with implementation in it) Visual Studio doesn't care. Even if I write some unexecutable statement in it, he lines it in red but doesn't bother anyway thus will just use an old, pre-compiled version. If I delete the "build-Debug" folder, he compiles the file again and it works as it should. Any ideas how to solve this problem?
I also realised that the "build-Debug" folder, contains no .obj file for all the header files with implementation in it. Maybe it has something to do with it?
Also, my general building properties are okay, like always compile when files change and such stuff.
I eventually solved the problem myself by just splitting the file into a seperate .h and .cpp file. While this was not my intention after all I could not find another solution for this problem. Thus it must have had something to do with being part of another .obj file and maybe with some include order or something similar.
I am new to programming with C++. So I am trying to inspect other's code to learn. I started inspecting a new prototype which has a function named myFcn. Its comment lines describe it requires mk.h, mk.lib and mk.dll files to be compiled. The project was successfully built. But when I go over the calling line of myFcn and press F12 (go to definition), the declaration prototype of myFcn appears and hitting again F12 does not bring me the body of the myFcn. I guess the function definition is in the mk.lib or mk.dll files. How can I find the body of the function?
EDIT 1:
If I had several dll and lib files, could I recognize the file that myFcn was compiled in?
It seems that the function you are trying to use is compiled in the library which you use.
The purpose of this system is to let people use your functions without the need for them to edit them or understand their source code. This means that the author of the library has written the function, and compiled it into a library (.dll, .lib and .h).
By including the .h file in your project, and linking the .lib at compilation and the .dll at runtime, you can use this function without the need to ever see more than the header file.
If you wish to understand the code of this function, go to their website, and see if they provide the full source code.
Edit based on edit of question: As far as I know there is no direct way to see which header file links to which library. It is possible to view which functions are in a certain library. On Linux this is the 'nm' command for .a files (gcc libraries). For Windows some methods are described here: How to view DLL functions?.
The function body is likely to be compiled, if then you can't see the source code of it.
first post and I'm pretty new to programming compared to most of you. I'm at a University and we have virtual linux machines that we usually code on and compile to. We've always had a command to instantly compile all programs in a file. Now I'm trying to be a big boy and use Visual Studio 2013 on my home computer. I'm having problem compiling. When I compile, it will only read through the main.cpp, even if I #include "blah.h" at the top. How do I set the compiler to check everything in my project.
I also don't get the point of the "build". I've never run across this before on our linux machines. We just write what we want, #include everything we use, and the compiler just reads it all and does it's job.
I'm a noob so don't judge. I am pretty good with all my knowledge, classes, pointers, data structures, I'm just a complete noob when it comes to compilers and IDEs. What is the difference in g++ compiler? My professor never talked much about IDEs and compilers aside from easy to use linux machine we have on campus.
TL;DR: How do I compile .hpp and .h in VS2013, always used easy peasy linux machine on campus.
You have to set up a project: File -> New Project, Under Visual C++ pick General and then create an Empty Project. Assume it is called Test1. Then, head over to the Solution Explorer, right click on Test1 and under Add, there should be Add Existing Items. Add your files and you are good to go!
You might want to read this question:Do I need to compile the header files in a C program?
In short, there is no need to compile the .h files since these .h files shall be included in the .cpp files.
In order to check everything in your project, the .h file shall be included in you main.cpp. In this case, the visual studio compiler shall precompile the cpp file which means the #include "test.h" will be replaced by the content of test.h .
What is the difference in g++ compiler?
"GCC has special treatment for files with .h extension when they are supplied to the compiler as command-line arguments."
Greetings fellow programmers! I am trying to create a C++ library to use in other projects. This library is to be a static library that will be linked to other projects.
Problem: The compiler doesn't seem to catch errors that it otherwise would if it were configured as an executable program under Project->Properties>General. In fact I purposely made a syntax error and the compiler
gave me a success regardless.
Is there a way to force the compiler to check everything while building a static lib?
Build Environment: Visual Studio 2010
EDIT: As it turns out, it was a rather simple, yet incredibly subtle mistake. It turns out that Visual studio was treating some of my .cpp files as header files. Because of this, the compiler was not running through the code at all (no one includes .cpp files). When adding files to the library, I must have accidentally selected header instead of C++ file. I thought Visual Studio would only rename the header file. I guess I was wrong!
This is nonsensical. It cannot happen. What is probably happening is that you think that the compiler is compiling your source file, (the one with the syntax error,) but it does not. Perhaps you have not added your source file to your project.
(Then again, C++ has a pretty quirky syntax; I hope you are sure that what you made was in fact a syntax error, and not a syntactically valid language construct.)
If you have more than one project in the workspace (solution) like exe and lib, make sure you click on the exact one to build or set it as the startup project (showing up in bold letters) if you hit the F7 button.
I'm a beginner starting to use Microsoft Visual C++ Express 2010 for Windows Programming. I've created a new C++ application using native code, not managed or MFC. I had Visual Studio create for me the basic windows code to create one window with simple menus (chat.cpp). I modified this file and I was able to compile correctly and see my changes take effect.
Now I've added one more source file to the solution (intro.cpp) which I include in my header and call from within chat.cpp. This seems to work just fine, but with one problem. The compiler doesn't seem to be applying my code changes occasionally: I make various edits, recompile, and the "old" code seems to be running. Then, after a while, after I make only a tiny modification, the compiler seems to "catch up" and it runs the new code including all the previous changes I had made.
Is there some kind of cache? Do I need to tell the compiler which files to compile and which ones to just link from object files? Did I make a mistake when I added the file to the solution?
Does intro.cpp have a header file? is that in your solution too?
It's hard for me to imagine that this area of such a mature IDE has a bug here, so I would examine your file list first. Make sure that the Solution Explorer shows all the files you have added and are editing. This is the list that VS uses to determine rebuild is needed.
EDIT: I admit it's not clear to me from your description why it would fail right now. However, typically header files do not include code, it works the other way around (except for class template header files, such as the STL headers). There is some discussion about pros and cons here. The most compelling argument to me in favour of code including headers rather than vice versa is that the header file contains the interface, while the code file contains the implementation.
I would try restructuring your code to a more traditional structure where intro.cpp includes intro.h and any others it needs, and the same with chat.cpp. Then your compilation units are intro.cpp and chat.cpp, and they depend on the associated header files, so provided they are properly listed in the SOlution Explorer, all should work. You can clean up the build dependencies to avoid dups and reduce build time once you have it working as you wish.