08-20-2013 04:33 AM
#include <utility.h>
#include <ansi_c.h>
#include <cvirte.h>
typedef struct StringsStruct
{
char A[10];
char AA[10];
char B[10];
char BB[10];
char C[10];
char CC[10];
} StringsStructType;
StringsStructType Strings = {0};
char *const SelectedStrings[3] =
{
Strings.A,
Strings.B,
Strings.C
};
int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
if (InitCVIRTE (hInstance, 0, 0) == 0)
return -1; /* out of memory */
strcpy( SelectedStrings[1], "TEXT" );
/*** FATAL RUN-TIME ERROR: "main.c", line 32, col 11, thread id 0xXXXXXXXX: Pointer to free memory passed to library function. ***/
Breakpoint();
return 0;
}
Any chance to get this working in CVI 2013?
"&Strings.A[0]" doesn't work either.
Solved! Go to Solution.
08-22-2013 05:47 AM
Hello CVI-User!
Thanks for reporting the issue. I have filed bug report # 423491.
I haven't had any luck getting rid of the error by changing the definition of the structure, but I was able to get the program running by disabling run-time checking when the structure fields are initialized:
strcpy( (char*)(uintptr_t)SelectedStrings[1], "TEXT" );
Or maybe a more descriptive workaround:
#define UNCHECKED(x) ((void*)(uintptr_t)(x)) strcpy( UNCHECKED(SelectedStrings[1]), "TEXT" );
Thanks,
Peter
09-05-2013 09:51 AM
Hi CVI-User,
Were you able to use the workaround provided to you by Peter? Is that acceptable to you for now?
09-06-2013 02:43 AM
Yes, thank you.
This works for me.