- Posts: 271
- Thank you received: 84
Custom halcomp with nested functions halcompile warning: implicit declaration of
- NWE
-
Topic Author
- Offline
- Elite Member
-
Less
More
10 months 3 days ago #340739
by NWE
I get around C++ coding some, but this halcomp thing has me confused. I am trying to call several functions within the _ function. As far as I can tell, what I have should work, but when I halcompile it I get these annoying warnings. I know they are just warnings, but I wouldn't mind fixing them.
In other C projects I sometimes use headers, etc, but I'm confused how this works in halcompile.
I searched around some, but can't seem to find examples of how what I'm trying to do would be done in halcomp.
sudo halcompile --install beam_pullmax.comp
Compiling realtime beam_pullmax.c
beam_pullmax.comp: In function ‘_’:
beam_pullmax.comp:213:5: warning: implicit declaration of function ‘y_stop’ [-Wimplicit-function-declaration]
beam_pullmax.comp:241:6: warning: implicit declaration of function ‘y_down_fast’ [-Wimplicit-function-declaration]
beam_pullmax.comp:286:6: warning: implicit declaration of function ‘y_down_slow’ [-Wimplicit-function-declaration]
beam_pullmax.comp:448:6: warning: implicit declaration of function ‘y_up_slow’ [-Wimplicit-function-declaration]
beam_pullmax.comp:467:6: warning: implicit declaration of function ‘y_up_fast’ [-Wimplicit-function-declaration]
Linking beam_pullmax.so
cp beam_pullmax.so /usr/lib/linuxcnc/modules/
Ah Ha! I think I got it! Just include a header file like any old C program...
I guess I'll post anyway now that it is all typed up, in case it saves someone else time on a future project.
In other C projects I sometimes use headers, etc, but I'm confused how this works in halcompile.
I searched around some, but can't seem to find examples of how what I'm trying to do would be done in halcomp.
sudo halcompile --install beam_pullmax.comp
Compiling realtime beam_pullmax.c
beam_pullmax.comp: In function ‘_’:
beam_pullmax.comp:213:5: warning: implicit declaration of function ‘y_stop’ [-Wimplicit-function-declaration]
beam_pullmax.comp:241:6: warning: implicit declaration of function ‘y_down_fast’ [-Wimplicit-function-declaration]
beam_pullmax.comp:286:6: warning: implicit declaration of function ‘y_down_slow’ [-Wimplicit-function-declaration]
beam_pullmax.comp:448:6: warning: implicit declaration of function ‘y_up_slow’ [-Wimplicit-function-declaration]
beam_pullmax.comp:467:6: warning: implicit declaration of function ‘y_up_fast’ [-Wimplicit-function-declaration]
Linking beam_pullmax.so
cp beam_pullmax.so /usr/lib/linuxcnc/modules/
Ah Ha! I think I got it! Just include a header file like any old C program...
I guess I'll post anyway now that it is all typed up, in case it saves someone else time on a future project.
Please Log in or Create an account to join the conversation.
- NWE
-
Topic Author
- Offline
- Elite Member
-
Less
More
- Posts: 271
- Thank you received: 84
10 months 3 days ago #340749
by NWE
Replied by NWE on topic Custom halcomp with nested functions halcompile warning: implicit declaration of
I celebrated too quick image missing /media/kunena/emoticons/sad.png
It compiles without a complaint, but trying to load it with loadrt beam_pullmax throws:
beam_pullmax: dlopen: /usr/lib/linuxcnc/modules/beam_pullmax.so: undefined symbol: y_down_slow
It compiles without a complaint, but trying to load it with loadrt beam_pullmax throws:
beam_pullmax: dlopen: /usr/lib/linuxcnc/modules/beam_pullmax.so: undefined symbol: y_down_slow
Please Log in or Create an account to join the conversation.
- NWE
-
Topic Author
- Offline
- Elite Member
-
Less
More
- Posts: 271
- Thank you received: 84
10 months 3 days ago - 10 months 3 days ago #340750
by NWE
Replied by NWE on topic Custom halcomp with nested functions halcompile warning: implicit declaration of
Progress... so I found this:
forum.linuxcnc.org/38-general-linuxcnc-q...ponent-help?start=10
And that is just what I wish to do; it even works. So now all I need to do is figure out what I did different.
Attached a working example for reference.
Wow, this could get interesting, having to reference hal pins by pointer...
And that is just what I wish to do; it even works. So now all I need to do is figure out what I did different.
Attached a working example for reference.
Wow, this could get interesting, having to reference hal pins by pointer...
Last edit: 10 months 3 days ago by NWE.
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
- NWE
-
Topic Author
- Offline
- Elite Member
-
Less
More
- Posts: 271
- Thank you received: 84
9 months 3 weeks ago #341214
by NWE
Replied by NWE on topic Custom halcomp with nested functions halcompile warning: implicit declaration of
I found a seemingly cleaner way: I changed the function names to variables that I set to 1 or 0 at places in the program where I wanted to call the functions.
Then I moved my nested functions to the end of the halcomp and rewrote them into if() checking which variables are set.
My original purpose for functions had been to avoid having duplicate blocks of code each place I want to run that sequence. The if()'s at the end serve my need just as well.
Then I moved my nested functions to the end of the halcomp and rewrote them into if() checking which variables are set.
My original purpose for functions had been to avoid having duplicate blocks of code each place I want to run that sequence. The if()'s at the end serve my need just as well.
Please Log in or Create an account to join the conversation.
Time to create page: 0.053 seconds