04-25-2013 04:52 AM
Hi
I have completed the "Getting Started Manual" (http://www.ni.com/pdf/manuals/373552g.pdf), and would like to extend my program by adding new *.C-files to the project. Here is the situation:
Say I add a single Quit-button to my canvas, and I want its function "CVICALLBACK QuitCallback" to be in an external file "quit_ext.c". Is there a smart way to do this, or doI have to manually create the header and C-file?
04-25-2013 05:14 AM
One possibility is to create a new file in the project file browser. Then, in the UI editor, you can choose the menu item Code / Set Targe File to select to which file your callbacks are added. Then use Code / Generate...
04-25-2013 05:54 AM
I can't get that to work. I start with a fresh project, add a Quit-button and a new ext.C-file. Then I set the Code Target File to ext.C and press Ctrl-G on the Quit-button (to generate code). When I compile, I get the error:
NON-FATAL RUN-TIME ERROR: "test.c", line 47, col 5, thread id 0x00000A90: The callback function, QuitCallback, specified in the UIR file, is not a known function. If you are using an external compiler, you must include the UIR callbacks object or source file in the executable or DLL.
Another thing is, that ext.C does not get its own header? That is probably the reason why it doesn't work.. do I have to add that myself?
04-25-2013 06:00 AM - edited 04-25-2013 06:02 AM
So your project consists of the files test.c, ext.c, test.h, test.uir?
In your C file calling the function QuitCallback, do you have a line such as
#include "test.h"
?
04-25-2013 06:13 AM
Yes, that is what my project consist of. And yes, I have "test.h" included in ext.C
04-25-2013 06:23 AM - edited 04-25-2013 06:27 AM
NON-FATAL RUN-TIME ERROR: "test.c", line 47, col 5, thread id 0x00000A90: The callback function, QuitCallback, specified in the UIR file, is not a known function. If you are using an external compiler, you must include the UIR callbacks object or source file in the executable or DLL.
The error suggests that you load your panel in the file test.c; on loading the panel, CVI checks if all callback functions are known, obviously QuitCallback is not known yet so you will need to include test.h in test.c, too.
04-25-2013 06:30 AM
But test.h is in test.c too, that is why I don't get it. Thanks for the links, I will take a look at them too at a later point.
04-25-2013 06:58 AM
For some magic reason it works now.. don't know why, I didn't change anything. But the conclusion is: The only extra thing that needs to be added is the C-file, the (single, unique) header-file LabWindows updates manually.