View Single Post
Posts: 7 | Thanked: 0 times | Joined on Aug 2010
#11
this require me to write my C code inside C++ file, that I do not know, and probably I will damage it.

Seems more easy to me, keep separate as much as possible the C++ and C, keeping them in different files.
For example the C++ code generated by QTCreator remain untouched with them methods, and the C algorithm in my hand written files the same. For sure I will add the C++ method invocation to my C part (like a C function call). It is possible?
Code:
// file GUI: C++ part generated by QTCreator
...
Code:
// file algorithm: C part hand written by me
...
/* other C code */
C++ method invocation
/* other C code */
...
and then compile both with a C++ compiler.

This let me have more confidence with algorithm file, because I understand error and warning better, as all the file is C syntax but the C++ method invocation only (I do not expect syntax error and problems on QTCreator generated files).
With this solution, the only thing I don't know (apart QT), is how to call a C++ method, the syntax needed (an example of course), taking care that arguments to be passed are variables defined with C syntax, keeping all previous C code intact.
This facilitate the port from a pure CLI C, and also from GTK+ C code.

I suppose will call functions by pointer, and pass variables by pointer (that it is probably what happen to C++ object code when is traslated to C at the start of compilation).

thanks