LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Cluster Containing Strings in C DLL as Struct

Solved!
Go to solution

Sorry! My bad. I should have elaborated.
I wanted to ask how to pass a cluster which contains nested clusters inside of it to a dll.
What should be the C struct be like. 

0 Kudos
Message 21 of 24
(232 Views)

@satagr wrote:

Sorry! My bad. I should have elaborated.
I wanted to ask how to pass a cluster which contains nested clusters inside of it to a dll.
What should be the C struct be like. 


Something like that:

Screenshot 2025-05-09 12.44.35.png

According C Code:

 

#include "extcode.h"
#include "lv_prolog.h"
		
// Define the structures
typedef struct {
	double X;
	double Y;
} ClusterC;

typedef struct {
	int N;
	ClusterC C;
} MainCluster;

#include "lv_epilog.h"

void ProcessCluster(MainCluster* cluster, int *N, double *X, double *Y)
{
	// Access the elements
	*N = cluster->N;
	*X = cluster->C.X;
	*Y = cluster->C.Y;
}

 

be careful with alignment in 32-bit environment.

0 Kudos
Message 22 of 24
(224 Views)

@satagr wrote:

Sorry! My bad. I should have elaborated.
I wanted to ask how to pass a cluster which contains nested clusters inside of it to a dll.
What should be the C struct be like. 


Sorry but this sounds weird. You want to ask about what C code you have to write to interface a certain LabVIEW data structure to C and have basically no good understanding of C?

If a cluster matches with a struct, why would a cluster within a cluster be anything else than a struct within a struct?

 

Having no understanding of C is even bad if you just want to interface LabVIEW to existing C code, but the other way around is just insane.

 

But there is a little trick that you can use if you still insist on that:

- Create your Shared Library Node with all the data types correctly connected to the terminals

- Right click on the node and select "Create .c file...'

- Enter a name in the file dialog to write into

- Open that file afterwards

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 23 of 24
(207 Views)

@Andrey_Dmitriev wrote:

be careful with alignment in 32-bit environment.


Correct use of the includes lv_prolog.h and lv_epilog.h around the declaration of the relevant data structures, as shown in your example, takes care of that.

And if you use the "Create .c file..." trick explained in my other post, it is done automatically for you.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 24 of 24
(202 Views)