09-27-2012 03:14 PM
I am going through the "Multithreading in LabWindows/CVI" tutorial.
The following line is in the tutorial regarding Thread-Safe variables:
"If you need to access the thread-safe variable from more than one source file, use the DeclareThreadSafeScalarVar or DeclareThreadSafeArrayVar macro in an include (.h) file to create declarations for the accessor functions."
Works OK with one source file, but when I include the header file in a second source file I get "Multiple definitions for symbol" errors at link time for all the accessor functions in both source files.
It's probably something simple, but after couple hours I'm at a loss. Any ideas are appreciated.
Scott T
Solved! Go to Solution.
09-27-2012 07:12 PM
You should have DefineThreadSafeXXX in exactly ONE source file and a corresponding DeclareThreadSafeXXX in any number of source files (or in a header file included in any source files). The following works for me in CVI 2012:
/* temp.h */
#include <utility.h>
DeclareThreadSafeScalarVar(double, Num);
void test(void);
/*temp.c */
#include "temp.h"
DefineThreadSafeScalarVar(double, Num, -1);
void main(void) {
InitializeNum();
test();
}
/* temp2.c */
#include "temp.h"
void test(void) {
SetNum(1.0);
}
09-28-2012 06:52 AM
Thanks, just what I needed.