Does Visual Studio support C++ code indexing? - c++

Does Visual Studio have a source code indexing feature for C++? That is, it statically parses your project, storing symbols in an index, such that you can easily and quickly jump to a definition of a symbol or see uses of it (i.e. call hierarchy)?
From what I can tell, in Visual Studio 2010, it has "Go to Definition" and "View Call Hierarchy" functions (if you right-click a symbol), but it takes a long time (a minute on my project) to find the info and do the action. It seems to be doing a crude text search in some cases.
I'm used to using Eclipse, which has an indexer, so those actions are almost instantaneous (after the indexing has completed).

Yes, Visual Studio Intellisense does just this. If your "go to definition" is taking a long time, it indicates that the project is not set up properly inside Visual Studio. You should be able to hover the mouse over a symbol (function name, variable name, etc.) and Intellisense should pop up instantly.
One cause of slow or incorrect Intellisense is creating a new project from a folder structure. If you have a bunch of .cpp and .h files in a complicated folder hierarchy, sometimes the project does not get created in a way that Intellisense can easily do symbol indexing. Also, if your project uses a lot of third party libraries, you need to make sure the header files are included in your project or else Intellisense will not be able to do anything with those symbols.

Related

How to Change the command line macros in Visual Studio 2017

I'm trying to create a Webots controller in VS2017 (through the webots software). When it loads up Visual Studio, everything is linked correctly and compiles correctly until I close VS and reopen it. Afterwards the macro of $(WEBOTS_HOME) changes to an incorrect path, which messes up the links to the files and libraries.
I tried to hard code the path in through properties editor, but it just says that all the files don't exist.
Links to error images:
Correct Macro Path
Incorrect Macro + Correct Hard Coded Path
Error From Hard Coded Path
Is there any way to change what this macro evaluates as, or a way to keep it from changing in the first place? After spending a couple hours on the internet looking for answers, I've determined that I can't add a user macro, which was my idea to replace the broken macro, because I can't access "Project Manager" Tab, only a console version.
The WEBOTS_HOME environment variable is indeed supposed to be defined (for a typical Webots installation: WEBOTS_HOME = C:\Program Files\Webots). It can be defined in your user environment variables. Doing this, it will be accessible from VS.

Visual Studio "hidden" preprocessor definition

In a project I'm working on, I have two preprocessor definitions (CPU_RENDER and GPU_RENDER) that control whether the build uses the CPU to render a scene or the GPU. I've been flipping back and forth between these two as I develop the software.
Suddenly, however, a few of the files claim GPU_RENDER is defined despite the fact that I removed it from Visual Studio's preprocessor definitions. Others work correctly. This isn't just visual, as the CPU build fails on link now, trying to find the source code for certain GPU only functions.
I've performed a search of the entire solution for "#define GPU_RENDER", just in case I did something stupid, but that came up empty. I then searched for every time I reference GPU_RENDER, but all those were just ifdefs.
I haven't used any new libraries so I don't think this could be a name collision.
Apparently the offending files had acquired their own set of preprocessor definitions. (I must have hit "Properties" with a file selected instead of the project at some point, making the file have a local set of definitions)
Deleting the file's personal definitions and ticking the "inherit from parent or project defaults" box solves the problem.

Function call without definition(in header, no dlls or static libs)

I have a embedded controller code handed over, it has a bunch on .c files and some headers and a lot of associated files for the embedded processor, its a motorola MC9S12DT256 and it uses a not-so-good compiler - Cosmic. i used Visual studio(just a txt editor) for modifying the code and it changes the hex file being burned to the processor.
I got it earlier this week and spent most of my time on it and it worked ok for minor changes (where changin a value in the code and compiling again made the necessary changes) Now i have to make some major changes. The code calls certain functions which are not to be found any where in the all of the .hpp/.h/.cpp i got. there are no associated dlls as well. I tried to find some basic link and put it in a .sln and still most data is not recognized (as in i cant go to declaration of defn).
So my question is - how to get to the function definiton to where it is called when VS blanks out. Find all references also does no help
Thanks
PM
They may be compiler intrinsics (functions provided by the compiler rather then in a library). But it is not clear how you have determined that they do not exist in a static library or why you think you should be able to see a definition (as opposed to a declaration).
When using Visual Studio as an embedded project IDE, you should create the project as a "makefile project" (even if you don't actually have a makefile), and you need to add all the necessary header paths for your embedded code and the Cosmic compiler standard header folder as include files to the project - VS scans the header files for declarations for Intellisense code completion and browser navigation.

Problems creating a static C++ library

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.

Visual Studio 2008 Navigation Bar Confused

I am refactoring a (rather long) C program using Visual Studio Professional 2008 (9.0.30729.4462 QFE). I use function picker drop-down in the navigation bar to jump between functions in the source quickly.
I added a function to the top of some source code and now the function picker drop-down in the navigation bar is just wrong. It sometimes jumps me to a different function, or inside another function.
I've tried cleaning, building, rebuilding the project, closing and reopening the project and even rebooting my computer, and nothing fixes this.
My supposition is that the IDE needs to rebuild its source code index, but I've been searching to no avail to location such a file much less how to force a rebuild.
Thanks!
Deleting the .ncb file and reopening the solution should fix the problem.
Visual studio parses your source code and stores the results inside the .ncb (Intellisense database). The file is used for auto-completion, class-view browser, etc... It usually rebuilds automatically, but sometimes it needs a manual clean.