Runtime add algorithm to a program [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm creating a program that make some matrix analysis. Now i want to implement some basic algorithms but I need to allow users implement new algorithms in the future without recompile the code.
I suppose that these algorithms already exist, probably in c/c++ language.
How can I do it if I use qt?
Maybe it's better use an other programming language and why?

I suppose that these algorithms already exist, probably in c/c++ language
If that's so, one way would be to write your program capable of loading DLLs, and then your users can compile their own algorithm DLL plugins for your application.
Or if you don't expect your users to be able to compile the existing c/c++ algorithms, maybe you can do as Joachim Pileborg suggests, and add in a scripting interface.

Related

Is calling C++ code from Swift more "expensive" or slower than calling C code? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have never tried Swift but my research suggests that callling pure C code is simpler than calling C++ code.
Does this mean that there are associated performance impediments and, if so, how significant are they?
Swift has no C++ interop at present. That means you either have to create a C or Objective-C++ wrapper around your C++ classes in order to bridge them to Swift.
In practice this is very unlikely to have a performance impact - it'll add another method call using VTABLE dispatch that in turn calls the C++ method. It does, however, create a lot more manual work that needs to be done in order to use your C++ code-base in Swift.

Making a decision tree for AI in C++ [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I know the basics of having a user input their decision as a choice, and having that lead to another decision. My only issue is that when i make these choices, it is almost all hard coded in, leaving no room for other uses of the code. I was wondering what the best way to make a decision tree for AI that would allow them to make smart decisions based on the circumstances. I DO NOT want the pre-written code or a library. I would prefer to write the code myself and learn more about the language. I have a good understanding of the language, but would still like to learn more.
You can embed a scripting language (e.g. Lua) into your application and let your users write their decision trees as scripts.
Or you can think of some data structure (XML-based for example) that describes an arbitrary decision tree that you can parse and build the actual tree during run time.

Programatically creating and compiling from a program in C++ [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Let's say we've got a first program called Program1.exe which contains the necessary information to create and compile another application called Program2.exe. Actually it could also load that information from a txt file or whatever.
Googling, I've found that this is "easy" to do in C#, using Visual Studio:
How to programatically build and compile another c# project from the current project
Programmatically Invoke the C# Compiler
The problem is that I'm not using (and can't use) C#, but C++. Summing it up, my question is if that I can do this same thing using C++.
I would prefer to do it without additional libraries, but if that's not possible, or if it's too hard to do, you can also recommend any library allowing it.
I think you'll probably have noticed it, but my goal is to use it under Windows so I don't care if it's not portable.
Thanks everybody.
It's trivial (if maybe a bit odd) for a C++ program to compile and run another based on code stored in a text file. Debugging that other program, however, isn't.

How to output to console window without iostream in c++? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm a beginner C++ programmer.I would like to know that Is it possible to output to console windows without using iostream header file?
the answer of the question is actually Yes ! but How?
You can always delve down to the C library level, using e.g. printf.
If you don't want to use the standard library at all then you have to use platform-specific functionality. In Windows there are many layers here, much like the C++ versus C layers in the standard library. The highest Windows API layer is the WriteFile function, and below that, WriteConsole, then perhaps WriteConsoleOutput, so on, check it out.
Note that there are at least two open source projects to provide more reasonable console functionality in Windows, namely Console2 at SourceForge and mintty at Google Code.

How to approach a C++ parser [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am wanting to have a go at a C++ parser for a formatter I am making.
You can obviously open a file and use getline(..) or get(), is this reasonable way of starting things off and then working out a system using vector arrays and hence creating loads of arrays and somehow structuring out and processing what you are doing from there. For example say I wanted to find ever function in a source file, all functions have the common syntax, "(){" once whitespace has been removed, so do you just look for common delimeters to parse out the sections into arrays. I suppose I will learn as I go.
Or I also assume there are tried and tested ways of doing this, and I would likley just be reinventing the wheel as they say.
C++ is a language that is quite hard to parse in the first place. So if you want anything other that really trivial C++ code to be "understood" by your parser, you are definitely better off starting with an existing product.
The Clang frontend library would perhaps be a good starting point.
There are also a number of "source to source" conversion examples based on clang. Here's one of them: http://eli.thegreenplace.net/2012/06/08/basic-source-to-source-transformation-with-clang/