Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Missing parameter type in thread-safe variable declaration

Hello,

I'm using LabWindows/CVI 5.5.1 on Win 98, and I'm trying to create a thread-safe structure that spans multiple source files. As per the multithreading tutorials, I have approached the task as in the following example. My header file contains the following:

------ 'shared.h':-------
...
typedef struct  // (I have found that if this structure is not listed before DeclareThreadSafeVar, I get several compile errors)
       {
         double x; int y; .....etc.
       } DAQ_DATA;

DeclareThreadSafeVar (DAQ_DATA, SharedData);
......                                                       ^^^^^^^^^^^^^^^ -> Build error flagged here for 'SharedData':   "missing parameter type"
---------------------------

The 'SharedData' variable is defined in ONE source file only, as follows:

------ myprogram.c------------
#include <utility.h>
#include "shared.h"
.....
DefineThreadSafeVar (DAQ_DATA, SharedData);  // Global scope
......
int main (void)
{
 ....
DAQ_DATA *tsPtr;
tsPtr = GetThreadSafePtrToSharedData();
tsPtr->x = 2.3;
tsPtr->y = 5;
.... etc.
ReleaseThreadSafePtrToSharedData();
.....

// spawned threads that also modify 'SharedData' by calling functions in other source files, etc
return 0;
}
-------------------------------

There are no compile errors, but how might I overcome that "missing parameter type" error for my 'SharedData' variable?
Thanks,
John.

0 Kudos
Message 1 of 3
(3,063 Views)

Hi,

  I've managed to get this to work by going through what the macros actually produce.

You don't need to do the Declare if you're doing the Define. The Declare is for making forward declarations so you can refer to functions before their actual functionality is defined. i.e. if your .c file #includes the one .h file, then you don't need the Declare in that .c file. Other source code files don't refer to the original .h file (if they did then they'd give Multiply define symbol link errors), then you need the declare in there so it can compile correctly.

Although you define the SharedData variable, you don't actually Initialise it at any point, so there's lots of definitions
of how it's supposed to work, but nothing on

InitializeSharedData

I'm attaching some code which should do what you need. The project is in CVI 8, but the source files should open fine.

Hope that helps

Sacha Emery
National Instruments (UK)

// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 2 of 3
(2,995 Views)
Thanks Sacha,
John.
0 Kudos
Message 3 of 3
(2,955 Views)