Using pow(base,exponent) in a custom component

More
17 Feb 2024 19:43 #293646 by MFairleaf
Hello, I'm getting a bit of a vomit from halcompile when I try to use rtapi_math.h to get access to a power function. Here is the offending code:

component powtest;
license "GPL"; // indicates GPL v2 or later
pin in float x_in;
pin out float z_out;
function _;
;;
#include <rtapi_math.h>
z_out = pow(x_in,3);

And here is the "vomit":

$ halcompile --compile powtest.comp

make KBUILD_EXTRA_SYMBOLS=/usr/realtime-3.4-9-rtai-686-pae/modules/linuxcnc/Module.symvers -C /usr/src/linux-headers-3.4-9-rtai-686-pae SUBDIRS=`pwd` CC=gcc V=0 modules
make[1]: Entering directory `/usr/src/linux-headers-3.4-9-rtai-686-pae'
  CC [M]  /tmp/tmpyFUQgz/powtest.o
In file included from powtest.comp:11:0:
/usr/include/linuxcnc/rtapi_math.h: In function ‘_’:
/usr/include/linuxcnc/rtapi_math.h:51:24: error: nested function ‘atan’ declared ‘extern’
/usr/include/linuxcnc/rtapi_math.h:51:24: error: static declaration of ‘atan’ follows non-static declaration
/usr/include/linuxcnc/rtapi_math.h:28:15: note: previous declaration of ‘atan’ was here
/usr/include/linuxcnc/rtapi_math.h:55:24: error: nested function ‘asin’ declared ‘extern’
/usr/include/linuxcnc/rtapi_math.h:55:24: error: static declaration of ‘asin’ follows non-static declaration
/usr/include/linuxcnc/rtapi_math.h:30:15: note: previous declaration of ‘asin’ was here
/usr/include/linuxcnc/rtapi_math.h:59:24: error: nested function ‘acos’ declared ‘extern’
/usr/include/linuxcnc/rtapi_math.h:59:24: error: static declaration of ‘acos’ follows non-static declaration
/usr/include/linuxcnc/rtapi_math.h:31:15: note: previous declaration of ‘acos’ was here
/usr/include/linuxcnc/rtapi_math.h:63:24: error: nested function ‘fmax’ declared ‘extern’
/usr/include/linuxcnc/rtapi_math.h:63:24: error: static declaration of ‘fmax’ follows non-static declaration
/usr/include/linuxcnc/rtapi_math.h:34:15: note: previous declaration of ‘fmax’ was here
/usr/include/linuxcnc/rtapi_math.h:66:24: error: nested function ‘fmin’ declared ‘extern’
/usr/include/linuxcnc/rtapi_math.h:66:24: error: static declaration of ‘fmin’ follows non-static declaration
/usr/include/linuxcnc/rtapi_math.h:33:15: note: previous declaration of ‘fmin’ was here
In file included from /usr/include/linuxcnc/rtapi_math.h:71:0,
                 from powtest.comp:11:
/usr/include/linuxcnc/rtapi_math_i386.h:11:1: error: nested function ‘sin’ declared ‘extern’
/usr/include/linuxcnc/rtapi_math_i386.h:11:1: error: static declaration of ‘sin’ follows non-static declaration
In file included from powtest.comp:11:0:
/usr/include/linuxcnc/rtapi_math.h:23:15: note: previous declaration of ‘sin’ was here
In file included from /usr/include/linuxcnc/rtapi_math.h:71:0,
                 from powtest.comp:11:
/usr/include/linuxcnc/rtapi_math_i386.h:12:1: error: nested function ‘cos’ declared ‘extern’
/usr/include/linuxcnc/rtapi_math_i386.h:12:1: error: static declaration of ‘cos’ follows non-static declaration
In file included from powtest.comp:11:0:
/usr/include/linuxcnc/rtapi_math.h:24:15: note: previous declaration of ‘cos’ was here
In file included from /usr/include/linuxcnc/rtapi_math.h:71:0,
                 from powtest.comp:11:
/usr/include/linuxcnc/rtapi_math_i386.h:13:1: error: nested function ‘fabs’ declared ‘extern’
/usr/include/linuxcnc/rtapi_math_i386.h:13:1: error: static declaration of ‘fabs’ follows non-static declaration
In file included from powtest.comp:11:0:
/usr/include/linuxcnc/rtapi_math.h:27:15: note: previous declaration of ‘fabs’ was here
In file included from /usr/include/linuxcnc/rtapi_math.h:71:0,
                 from powtest.comp:11:
/usr/include/linuxcnc/rtapi_math_i386.h:14:1: error: nested function ‘sqrt’ declared ‘extern’
/usr/include/linuxcnc/rtapi_math_i386.h:14:1: error: static declaration of ‘sqrt’ follows non-static declaration
In file included from powtest.comp:11:0:
/usr/include/linuxcnc/rtapi_math.h:26:15: note: previous declaration of ‘sqrt’ was here
In file included from /usr/include/linuxcnc/rtapi_math.h:71:0,
                 from powtest.comp:11:
/usr/include/linuxcnc/rtapi_math_i386.h:16:24: error: nested function ‘tan’ declared ‘extern’
/usr/include/linuxcnc/rtapi_math_i386.h:16:24: error: static declaration of ‘tan’ follows non-static declaration
In file included from powtest.comp:11:0:
/usr/include/linuxcnc/rtapi_math.h:25:15: note: previous declaration of ‘tan’ was here
In file included from /usr/include/linuxcnc/rtapi_math.h:71:0,
                 from powtest.comp:11:
/usr/include/linuxcnc/rtapi_math_i386.h:23:24: error: nested function ‘atan2’ declared ‘extern’
/usr/include/linuxcnc/rtapi_math_i386.h:23:24: error: static declaration of ‘atan2’ follows non-static declaration
In file included from powtest.comp:11:0:
/usr/include/linuxcnc/rtapi_math.h:29:15: note: previous declaration of ‘atan2’ was here
make[4]: *** [/tmp/tmpyFUQgz/powtest.o] Error 1
make[3]: *** [_module_/tmp/tmpyFUQgz] Error 2
make[2]: *** [sub-make] Error 2
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.4-9-rtai-686-pae'
make: *** [modules] Error 2

My next step is to try to reproduce the error on another PC with the current image of LinuxCNC to determine if this is a bug which has already been fixed.

Please Log in or Create an account to join the conversation.

More
17 Feb 2024 21:24 #293652 by MFairleaf
Update: It works on a 64bit silicon, just not 32bit.
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

More
17 Feb 2024 21:33 #293657 by tommylight
I wonder what would cause that?
32BIT is quite old, so maybe that?

Please Log in or Create an account to join the conversation.

Time to create page: 0.310 seconds
Powered by Kunena Forum