The manual (https://www-fourier.ujf-grenoble.fr/~pa ... r1118.html)
discusses translating Xcas programs into C++ programs, and gives an example
truc(n:integer) := {return 2*n+1;}
then
cpp(truc)
When I try that, I get the message
File giac_truc.cpp created.
Running indent -br -brf -l256 giac_truc.cpp
Running
c++ -I.. -I. -fPIC -DPIC -g -O2 -c giac_truc.cpp -o giac_truc.lo
Unable to compile, please fix cpp file
The file giac_truc.cpp is there (I've attached a copy, it's a bit different than the manual version),
and when I try
c++ -I.. -I. -fPIC -DPIC -g -O2 -c giac_truc.cpp -o giac_truc.lo
from the command line, I get
[~]> c++ -I.. -I. -fPIC -DPIC -g -O2 -c giac_truc.cpp -o giac_truc.lo
giac_truc.cpp: In function ‘giac::gen giac::truc(long int, const giac::context*)’:
giac_truc.cpp:13:24: error: expected primary-expression before ‘return’
giac::makevecteur (return 2 * n_i + 1)
^~~~~~
giac_truc.cpp:14:3: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
How can I fix the cpp file?
Jay
Translating to C++
Modérateur : xcasadmin
Translating to C++
- Pièces jointes
-
- giac_truc.zip
- (582 octets) Téléchargé 86 fois
Re: Translating to C++
return should be before makevecteur, not inside. I must fix something in the C translator. Perhaps the best is not to translate this chapter, it's still experimental.