Checking how many members is there in a class [duplicate] - c++

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
C++ macro/metaprogram to determine number of members at compile time
is there a way to detect at compile time how many members class has?
I've looked the web but no results.

There are API's for static analysis tools that could do this.
Here at my work I use a product called understand 4 C++. It has a nifty C API, for which I wrote a managed C++/CLI wrapper API. That allows you to write tools using C# to target their API. Using this I have written tools that do things similar to what you want to do.
In your case, you could write a tool, get it to do what you want, and then call this tool as a post build event.
If you search this website for static analysis API's then you will find other useful hits.

Related

Tool to generate call graphs for c/c++ code on windows platform? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Tools to get a pictorial function call graph of code
I have some c/c++ code . I want to know any tool that can be used to generate call graphs , giving information regarding caller,etc on windows platform.
Doxygen can create call graphs
http://www.doxygen.nl//manual/diagrams.html
You can try also CppDepend , it comes with a dependency graph with many features and possibilities, and you can use CQLinq to request your codebase and see the dependency graph for a subset of your codebase.

Seeking C++ implementation of `hires_time_in_seconds()` [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
High resolution timer with C++ and Linux?
double hires_time_in_seconds();
I'm looking for this function for Windows, Linux too if you have it.
It is mentioned in http://gafferongames.com/game-physics/fix-your-timestep/.
I've looked on the web.
I know it's not a standard function but if anybody has an implementation that they want to share, that would be great.
Failing that, I need something as fine grained as possible to do synchronization in a client server game.
It's not a real function, it's just a self-descriptive placeholder name used in that blog post's example code.
For Windows, you'll want to use QueryPerformanceCounter along with QueryPerformanceFrequency. For Unix-based OSes, you'll want to use gettimeofday(3).

Is there a tool to draw a graph representation of my c++ classes and methods? [duplicate]

This question already has answers here:
Closed 11 years ago.
Is there a tool to draw a graph representation of my c++ classes and methods ?
In other words -- as G++ may do it already to check for circular dependencies between headers -- is there a tool that can actually show me how my classes and methods interact with each other ?
Not an exact duplicate of Class dependency tool
I'd like to be able to not only see static dependencies between classes but also between methods.
Is there an open source tool, or at least working under Linux?
doxygen does a neat job of it. I suggest using the DoxyWizard GUI.
See online demos: http://www.doxygen.nl/results.html
This is a better link, though very very simple:
http://www.doxygen.nl/manual/examples/diagrams/html/inherits.html
It serves as a demonstration of principles in the documentation for graphing in Doxygen:
http://www.doxygen.nl/manual/diagrams.html
If you want to do heavy-weight analysis, look at CppDepend.
As an answer to the request for dynamic call graphs, may I suggest KCachegrind
It works well on linux (and MacOS, per the comment) in combination with Callgrind:
valgrind --tool=callgrind ./myprogram
kcachegrind
Presto! But valgrind only works on linux. I know there are quite a few profilers that have output convertors to kcachegrind readable format. I don't use them, so I'm afraid there would be some google work in it for you

parser for c++ headers to extract functions with standard linux tools? [duplicate]

This question already has an answer here:
Closed 11 years ago.
Possible Duplicate:
parser for c++ headers to extract functions with standard linux tools?
is there something like this? need to extract c++ functions from header files with all the parameters they use. would be nice if i can use standard linux programms
You can use a program called 'understand 4 c++'. What it does is parse your program like a compiler. However instead of spitting out executable code, it just creates relationships that you can browse your source code (Like Intellisense in visual studio).
However it is very powerful. The best and my favorite part is that it exposes a very powerful API that allows you to write your own static analysis tools.
So in essence, just dumping all function signatures in header files is a snap using this API.

Whats the difference between C++ and C++ CLI [duplicate]

This question already has answers here:
What is the difference between ANSI/ISO C++ and C++/CLI?
(2 answers)
Closed 7 years ago.
I'm learning C++ (CLI apparently), and every time I post a question saying that I am using C++, someone jumps down my throat saying that I'm not using C++, but C++/CLI. I'm not really sure of a difference, as I am extreamely new to this, but it seems to make everyone upset. Can anyone shine some light on the differences?
As a second note, the reason I am asking this is because it was suggested that I use CLI to be able to make a method accessible to my C# project. I have everything running fine in my C++ project, through my constructor, but now I would like to be able to call those same methods from my C# project.
C++ CLI runs on the "Common Language Interface". This basically means that when it's compiled, the compiled code will end up being allot like the byte code produced via C#.
C++ CLI has a ton of extensions added to it such as Garbage Collection that do not exist in C++. C++ CLI also allows for "safe" C++ code. In this mode you're not allowed to use pointers. There's no such thing as "safe" code in C++ it's all "unsafe". C++ CLI can be nice for interfacing .NET code and C++ libraries, but besides that, I haven't found a use for it.
The Wikipedia page has a good overview: http://en.wikipedia.org/wiki/C%2B%2B/CLI
And yes, they are right to jump on you for being able to program in C++ CLI will not allow you to program in C++....they are different enough that you cant just mix them.
AFAIK, C++ CLI allows you to have access to the .net framework.
It offers some garbage collection and few other specific features not on C++
C++ runs directly as binary complied for your hardware. C++ cli is a c++ extension that is used to interface with the MS common language runtime. It complies to IL normally and is executed inside the .net runtime. There are numerous differences between the two some of the major ones being garbage collection and how inheritance and interfaces work.
The reason to use c++Cli is gain the advantages of using the hundreds of classes provided to you by the framework. These are all accessible from any CLR compliant language so some have been left to wonder why one would use c++ to access the framework, unless you are linking into some legacy code.