El 24/10/2016 a las 1:40, Lars escribió:
Hi, what is the status of automated conversion tools? Last I remember
reading about them was when I read a delphi page on how to convert header
files. Are you saying that nowadways you can actually convert plain C code
to fpc, not just header files but all C code? Just certain types of C
code? Are there any competing tools or everyone uses just one main tool?
Hello,
I don't know, wrote this tool to help me in the past to translate Zint
barcode source from C to pascal, in special the maths involving "++",
"--" and other funny "C" expressions.
It is far away from a real code translator, and it is dummy as it does
not analyze the type of each variable, instead it uses them as a
variable of any type and it simply try to put it in the same context as
the "C" one. When it finds things like:
if (a) { ...
It will convert it to
if IsTrue(a) then ...
So you must provide an IsTrue function for that case (integer, char,
byte...) and many times you need to manually adjust some lines.
Or if it finds:
a++;
It will output:
PostInc(a);
Where PostInc is:
function PostInc(var aValue: integer): integer;
begin
Result:=aValue;
aValue:=aValue + 1;
end;
It uses GoldParser so maybe it only works in Windows :-?, only very
basic "C" is handled and is mostly function by function oriented.
If you want to test it I can provide .exe or source code, but do not
expect it to translate anything far than some trivial functions.
--
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal