parser for c++ headers to extract functions with standard linux tools? - c++

Is there something like this? I need to extract C++ functions from header files with all the parameters they use. It would be nice if i can use standard Linux programs

You can use understand 4 C++ which is a front end tool that browse your source code and generate metrics for your source code. It also has a powerful API that allows you to write your own static analysis tools. So far understand works on windows, and a bunch of other linux based OS's. Though I've only used the windows based API.
It is found at:
http://scitools.com/

Related

How can I parse C++ code in a prebuild event?

I have a prebuild-event tool (written in Ruby) in my C++ toolchain, that generates additional C++ code from existing C++ source code. I would like to replace this tool with a faster generator and using clang would be the best option.
Is there a way to write a C++ application that parses C++ source code of a file, so I can implement this prebuild tool in Clang? I am looking for a keyword or page with how to start. Any help is highly appreciated!
Parsing C++ is not a simple thing. Compile-time trickery and implicit semantics make it incredibly hard. Because of this I would suggest going with Clang. Its developers made it possible to use Clang as a library. Check out this guide to see different interfaces Clang has. If you want real C++ experience you might want to choose LibTooling.
I want to warn you though that in order for any C/C++ parser to work as expected they absolutely need compilation options used by the real compiler. Without include directories or macro definitions the code can make little to no sense. Basically your build system should tell your custom tool how to compile each file. The simplest approach would be using compilation database. It is a go-to solution for many Clang-based tools. However, it looks like you're making it a part of your build system, so maybe incorporating your tool and using options directly from the build system can be not such of a burden for you.
I hope this information is helpful!

Link c++ object during runtime?

I'm trying to write my first game in c++, and I want it to dynamically load everything from files. This includes the enemies, and I was wondering if there was a way to dynamically include their code at runtime, instead of linking the on compile, so that the levels are easily interchangeable. Lua might be an option but I have no clue where to start, and dll seems to be Windows-only (and I wouldn't know where to start there anyway). Can anyone help with this?
tl;dr I want to link in code to my c++ game at runtime.
For the Lua approach you first need to choose the version first. Right now there is the major version 5.1 and 5.2. My previous work was using 5.1 and for my new project I decided to update to 5.2, however I found that my favorite script wrapping tool (SWIG) does not work with 5.2. Just something to decide at the beginning, because you do not want to get a version working and then have to change it.
Lua comes with makefile build environment. My first experience of trying to build on Windows was a bit of a nightmare, did not appear to just run out-of-the-box, so I opted to create my own Visual Studio project at the time, and just include all the .C files in the project. There are two files which need to selectively included/excluded depending on how you intend to compile: lua.c and luac.c. If you are planning to embed Lua in your app, then exclude both of these files; they both contain a main() function and are designed to build console apps. Include all the rest of the C files in your project.
You should be able to compile easy from this point.
When you include the headers of Lua, keep in mind that the functions are C functions so if you are including them from C++ you need to wrap the file inclusion inside of: extern "C" {} - example: C++ Lua 5.1 Issue
Wrapping your interfaces in another topic and there are lots of resources available. My favorite is SWIG but there are lots of options, including hand coding the conversion of your C/C++ -> LUA -> C/C++ code. Would recommend just focusing on getting the first part working first, get the interpreter embedded so that you can run a "hello, world!" script from Lua inside your app.
So going by your requirement of crossplatform use and dynamic linking, what you're probably looking for is an environment like QT which has QLibrary: https://stackoverflow.com/a/9675063/453673
But https://softwareengineering.stackexchange.com/questions/88685/why-arent-more-desktop-apps-written-with-qt
MingW is the open-source equivalent for Visual C++, so it can help you writing code for Windows (though if I had a choice, I'd directly use Visual C++). The way dll's are loaded in Windows is somewhat similar to the way they're loaded in Linux, so you'll be able to write code with #ifdef's to do conditional compilation. I've written one such program a couple of years back.
To load a shared library(always with .so as suffix) under Linux, you could use dlopen(), dlsym() and dlclose()

Software auto gen document on Eclipse

I have a project which was designed by SOAP. It was opened on eclipse.
I would like to use a software for auto generate a document(html file) for developer tutorial .
It was generated by comment on above function.
Thanks,
Use oxygen as stefan already said, it's free and you can get it here: http://www.doxygen.nl/download.html
Generate documentation from source code
Doxygen is the de facto standard tool for generating documentation
from annotated C++ sources, but it also supports other popular
programming languages such as C, Objective-C, C#, PHP, Java, Python,
IDL (Corba, Microsoft, and UNO/OpenOffice flavors), Fortran, VHDL,
Tcl, and to some extent D.
Doxygen can help you in three ways:
It can generate an on-line documentation browser (in HTML) and/or an
off-line reference manual (in ) from a set of documented source files.
There is also support for generating output in RTF (MS-Word),
PostScript, hyperlinked PDF, compressed HTML, and Unix man pages. The
documentation is extracted directly from the sources, which makes it
much easier to keep the documentation consistent with the source code.
You can configure doxygen to extract the code structure from
undocumented source files. This is very useful to quickly find your
way in large source distributions. Doxygen can also visualize the
relations between the various elements by means of include dependency
graphs, inheritance diagrams, and collaboration diagrams, which are
all generated automatically. You can also use doxygen for creating
normal documentation (as I did for the doxygen user manual and
web-site). Doxygen is developed under Mac OS X and Linux, but is
set-up to be highly portable. As a result, it runs on most other Unix
flavors as well. Furthermore, executables for Windows are available.

Accessing libraries written in OCaml and C++ from Ruby code

I'm writing a Ruby program and I want to use the following libraries in it:
LTL3 tools
AT&T FSM library
LTL2BA library
LTL3 tools are written in OCaml, AT&T FSM library is written in C++, LTL2BA library is written in C++. LTL3 tools have dependencies on AT&T FSM library and LTL2BA library. I have both executables and source code for all those libraries.
How can I access all these libraries from Ruby code? Sorry for noob question, it's my first week in Ruby. BTW I'm using Linux Ubuntu if that helps.
The simplest way to interact with a library written in a different language is not to find an API bridge to make it run as part of your program, but to have it run as a different process to which you pipe data (in text format, or whatever it easily supports).
From the description, L3LTools seems to be used for converting some sort of stuff into another sort of stuff, and it can read and print them in a documented textual format, and there is a shell script wrapper that does the plumbing for you.
You don't even need to know in which language it's written in. Just get a parser for its output format, a printer for its input format, and call the script from your code.

Embedding Mono vs Google V8?

We want to add scripting to a project.
We are hesitating which script engine to use.
I have used in the past V8 and it's quite impressive. I have used Mono as well but in toy-projects or prototypes only.
The constraints are :
speed of execution.
easy integration.
must work on windows.
64-bit support.
compiles under Visual Studio.
Which engine fits the best ?
(Are there any tutorial for compiling Mono under win64 with Visual Studio?
Is there some packages that include Lib files and DLLs ?)
I would suggest you to take a look at Lua. I think it fits your needs quite satisfactorily.
Since there are no upvoted answers, I'm going to mention ChaiScript (Yes, I'm a co-creator of the project). It's a header only scripting engine designed solely for embedding in C++ applications. It has full 64bit support and works with MSVC, G++ and MinGW. The only external dependency is boost.
Where it does not win is speed. If you need to do a lot of calculation in the script itself, well, I argue that you are using scripting wrong. The higher level the function you can expose to the scripting engine, the better.
V8. It actually is a scripting engine rather than a full programming environment like Mono (which rivals Java for size).
However... if you want a scripting language, you might also want to have a look at Lua. It's famously easy to embed, really fast, really small, pretty easy to program for, and has a very liberal license. If speed's important there's LuaJIT, which is still under development but with care will handily beat C for numerical programming.
There is an MSVS solution file included into Mono distribution, it is enough for building a library (but you won't be able to build .DLLs, better pick them from a binary distribution). See mkbundle for a way to embed .NET DLLs into a single binary. As for scripting itself, you can either embed Mono C# compiler (it is not that big, and it is easy to integrate) or use any of the numerous scripting languages that target .NET - e.g., IronPython.
Python isn't bad either, with Boost.Python.