doxygen extern variables indexing - c++

I just started to use doxygen and may not be familiar with all available settings. I looked into all tags and options in configuration file, but havent been able to locate any relevant tag for the operation.
Is there any way to force doxygen to index externals in C/C++ ? Now they just plainly added to list of other variables in the source file.
EDIT: From what I have seen so far, is that doxygen doesnt understand the externals at all. It generates a references in html files for these variables or functions to random ( first seen ) locations

Local variables with file-only scope are marked as static, right? So when setting EXTRACT_STATIC to NO you won't see them at all.
That said: there is now no clear distinction between static and external variables in the index. I have plans to redesign the indexes to make them more interactive and then I will take your wish along (i.e. be able to filter on static v.s. external). If you want to be notified on when this happens please file a bug report with severity set to enhancement in doxygen's bug tracker.

Related

How to get VS Code to propose more limited rename?

In Visual Studio Code, F2 rename on purely local C++ symbols is fine, but trying it on a symbol with wider scope, results in a very aggressive scope of suggested renaming, going as far as suggesting to rename unrelated symbols with the same name in the system header files. These typically default to unchecked, but at one point, it did rename an unrelated symbol with the same name in a project header, so it would be nice if the default could be dialed down a bit. Is there a way to do that?
The problem isn't with vscode, it's the linter vscode is using.
The easiest way to try to resolve the problem is using a different more advanced c++ linter. It's what I did to resolve a similar issue using golang.
Maybe the below link will help you find your new favorite linter.
https://www.reddit.com/r/cpp/comments/5b397d/what_c_linter_do_you_use/
PS: There is probably a setting that can edit the linter like what I am posting below, but based off of what you're asking, it may be difficult to find the right regex or whatever you need. It'd probably be best just to switch linters and then maybe make an issue on their github repository if you can't find one that suis your need.
"python.formatting.blackArgs": [
"--line-length=80"
],

Doxygen: Having "Modules" twice in the Table of Content with Fortran Code

I am currently documenting a F95/2003 software project with the help of doxygen. On the one hand I grouped corresponding pages with the help of #defgroup, #addtogroup, #ingroup.... which end up under the point Modules in the table of contents and the top menu. Then the project also contains Fortran Modules, properly documented, and they appear also as a separate Modules point in the table of contents, which makes them hard to distinguish. How can I rename one of them? Like naming the Module pages generated from the Fortran modules' documentation as Fortran Modules or the best option would be to get completely rid of the separate Modules pages for the Fortran modules, since they also belong to a doxygen group and can be found there asl well?
In principle the "Fortran modules" are listed as namespaces, but by means of the OPTIMIZE_FOR_FORTRAN = YES the name is changed into "Modules". To get the correct naming is of course a difficult problem.
Doxygen has also the possibility to change, in respect to names and showing / hiding) some layout elements, see the doxygen manual paragraph: "Changing the layout of pages" (http://doxygen.nl/manual/customize.html#layout).
when creating a layout file say:
doxygen -l mylayout.xml
and changing here the line (approximately line 8):
<tab type="namespaces" visible="yes" title="">
into
<tab type="namespaces" visible="yes" title="Fortran Modules">
and setting in the doxygen configuration file (Doxyfile):
LAYOUT_FILE = mylayout.xml
I think you get the effect you want to have.
The following I didn't try (so I don't know what the effect might be in your case, and I have big doubts but I mentioned it here for completeness as it came into my mind), but doxygen has also the \namespace command maybe you can use this in this case in stead of the grouping commands.

VS2010 does not find #include via environmental variable

I'm currently running into a problem that drives me a little bit mad. I hope it's a little stupid mistake on my side.
For convenience, I added an environmental variable in Windows 7, VS_BOOST_INCLUDE_HEADER with the value set to D:\01_Programs\boost_1_55_0\. My VC C++ include directories contain $(VS_BOOST_INCLUDE_HEADER).
Remark: I changed that variable this morning, but I've rebooted my computer since than multiple times.
Now my VS project complains it can't find any of the boost includes anymore, e.g. <boost/asio.hpp>. If I add the whole path manually to the include paths (adding D:\01_Programs\boost_1_55_0\ as text to my VC C++ include directories), everything works as expected.
To avoid a simple typo, I added a post-build event:
echo $(VS_BOOST_INCLUDE_HEADER)
That works as expected:
1>PostBuildEvent:
1> D:\01_Programs\boost_1_55_0\
All my other environmental variables still work as expected, even those that were renamed this morning as well.
Any ideas?
What am I doing wrong?
Maybe I'm late to the party, but a possible scenario is when you
run VS as administrator
adjusted a User environment variable
Then it would make some sense for VS to see the System environment only and still use the old value.
If you decide to use property sheets the msdn has clear docs
"If you have a common, frequently used set of properties that you want
to apply to multiple projects, you can use Property Manager to capture
them in a reusable property sheet file"
Under the view menu, chose property manager and add a new sheet.
You can then make your project inherit its settings from this property sheet, thereby just setting this in one place.

Doxygen optimization

I am trying to figure out how I can optimize Doxygen to run on my project in a reasonable amount of time. I have tried to use Tag files and divided my project up into subprojects so that I can parallelize/distribute the load of a Doxygen run. However, it appears that this feature is solely intended for linking to external documentation and not for joining projects in the way that I would like to.
I have used the ALLEXTERNALS tag to have my subproject class included in my main project however they are all tagged [external] and they only show up in the class list tab and not the class index or class hierarchy tab.
Does anyone have any ideas on how I can parallelize/distribute Doxygen or, if not that, does anyone have any optimization tips?
Have a look at my answer here: https://stackoverflow.com/a/8247993/784672
Tag files can be used to link projects together, but they have their limitations in terms of integration (if the result would be the same there would be no performance advantage).
That said: if you think entries are missing from the index then please file a bug report in the bug tracker.

How to find all global variables in C++ source code, DLL or any file created by the VC++ compiler?

I'm making my application thread-safe. One of the steps is to synchronize access or eliminate usages of global variables. I'm using Visual Studio. I can't find any good way to find all global variables in my codebase. It's impossible to create a good text search pattern and I can't find any helpful tool. Do you guys know any good way to do that? It could be a source code analysis tool or a binary file analyzer.
This could help:
Open the project in visual studio.
Open 'Class View' of the project
Under the project title, you will find 'Global Functions and Variable'.
I have checked this with Visual Studio 2010 and above.
Edit: As suggested by Ajay in comments, you could also categorize items in groups. For grouping items:
In class view, right click on project title
Select `Group By Object/Member Type'
Select the required tree like variables or structures or enums etc.
One option might be letting the linker generate a map file (/MAP in Visual Studio).
You will get a .map file for each binary with two sections:
A table of segments
Start Length Name Class
0001:00000000 00010000H .textbss DATA
0002:00000000 000034b4H .text CODE
0003:00000000 00000104H .CRT$XCA DATA
0003:00000104 00000104H .CRT$XCAA DATA
0003:00000208 00000104H .CRT$XCZ DATA
0003:0000030c 00000104H .CRT$XIA DATA
...
A list of symbols (functions and data)
Address Publics by Value Rva+Base Lib:Object
0000:00000000 ___safe_se_handler_count 00000000 <absolute>
0000:00000000 ___safe_se_handler_table 00000000 <absolute>
0000:00000000 ___ImageBase 00400000 <linker-defined>
0001:00000000 __enc$textbss$begin 00401000 <linker-defined>
0001:00010000 __enc$textbss$end 00411000 <linker-defined>
0002:000003a0 _wmain 004113a0 f console4.obj
...
You can tell apart the functions from variables by the "CODE" / "DATA" designaiton in the segment list.
Advantage: You will get all symbols, even those in libraries, that were not removed by the Linker.
Disadvanatge: You will get all symbols, even those in libraries, that were not removed by the Linker. I don't know of any tool that does the code/data separation automatically.
I know the http://code.google.com/p/data-race-test/wiki/ThreadSanitizer program (product of google) which can work in Windows and on compiled code. It is dynamic instrumentation program (like valgrind or bit like qemu/virtualbox), which add some checks to memory accesses. It will try to find some threading problems. You can just run your program under control of threadsanitizer. There will be slowdown from dynamic translation and from instrumentation code (up to 20x-50x times slower). But Some problems will be detected automatically.
It also allows you to annotate some custom synchronization functions in source code.
Wiki of program has links to other thread-race detectors: http://code.google.com/p/data-race-test/wiki/RaceDetectionLinks
cppclean is a static analysis tool that can help you. From the documentation:
cppclean finds global/static data that are potential problems when using threads.
A simple example with a static local variable and a global variable follows.
./example.h:
void foo();
./example.cpp:
#include "example.h"
int globalVar = 42;
void foo(){
static int localStatic = 0;
localStatic++;
}
Open a terminal and run cppclean as follows:
$ cppclean --include-path . example.cpp
example.cpp:3: static data 'globalVar'
example.cpp:6: static data 'localStatic'
Unfortunately, cppclean has some parsing issues and bugs. However, these issues are pretty rare, and affected below a percent of all code I've tested.
You can try CppDepend by using its code query language
from f in Fields where f.IsGlobal select f
Maybe dumpbin tool will help here. You can run it with /SYMBOLS key to display the COFF symbol table and look for External symbols - global variables should be in this list. DUMPBIN /SYMBOLS.
You all are making this too complicated.
1.
Copy the code of each of your files (one at a time separate from the others) to a string or a wide string or etc. and then parse out everything that is from "{" to "}" uninclusive. Save the result to an exterior file. After the first time, then append to that file.
2.
Even if you have 1,000 lines total of what is left after all that parsing, in that are all of your globals (depending upon how you created the globals). If you created them via a namespace, etc. then go back and parse for that. I doubt that most programmers will have 1,000 globals, but for some applications it might be what they use. If you do not have too many at that point then manually edit that text file of the results.
I have found that maybe 90+ % of the answers on this site are bloated with far too much complexity that just eats up cpu time and memory space. Keep it simple.
You might find it handy to have a globals.h file which you load early and keep most or all of you globals there. It looks like time to do a lot of clean up.