Page 1 of 1

C integration with ARRAY VAR

Posted: 23 May 2019, 12:07
by Carlo
Good morning,
I'm integrating some C code into a logi.CAD 3 project and I need to define the interface for a C-block.
One of the interface variable has to be an ARRAY OF STRING, as show in the code below:

Code: Select all

{extern_c}
FUNCTION_BLOCK readConfigurationFile
	VAR_INPUT
		filePath : STRING[256];
	END_VAR
	VAR_OUTPUT
		content : ARRAY[1..100] OF STRING[256];
		//content_test : ARRAY[1..100] OF DINT;
		//content : STRING[25600];
		content_first_line: STRING[512];
		readLines : UDINT := 0;
	END_VAR
	
END_FUNCTION_BLOCK

And here the C function definition where I would like to access to the variable defined:

Code: Select all

#ifndef LC_PROT_LCFU___READCONFIGURATIONFILE__C
#define LC_PROT_LCFU___READCONFIGURATIONFILE__C

#define _GNU_SOURCE
#include <lcfu___readconfigurationfile.h>
#include <stdio.h>
#include <stdlib.h>

#define V(VAR) (LC_this->LC_VD_##VAR)

/* dimension nodes */
/* array nodes */
/*                            FunctionBlocks                   */
void  lcfu___READCONFIGURATIONFILE(LC_TD_FunctionBlock_READCONFIGURATIONFILE* LC_this, struct _lcoplck_epdb_1_impl* pEPDB)
{
	V(READLINES) = 0;
//		V(CONTENT)[0] = "e";
//		V(CONTENT)[0] = 10;
}
#endif

When I try to build the application the following generic error message appears (the “Problems” tag is empty):

Cattura.PNG
Cattura.PNG (33.52 KiB) Viewed 32726 times

The same happens when I use ARRAY OF DINT.
If I comment the ARRAY definition in the interface file, the build is successfully.
I would like to know if I miss something.

Carlo

Re: C integration with ARRAY VAR

Posted: 27 Apr 2023, 08:05
by u.biakoup
Hello Carlo,
For all questions about Logi.CAD3 software, contact Logicals Support.
Best Regards

Ulrich Kouatang Biakoup | Technical Support