Getting undeclared error for the variable which is already declared.
I have this piece of code to compile with insure++
static int ABC
(
unsigned char *buffer,
int buffer_size,
int num,
)
{
memset(buffer, '\0', buffer_size); void* xyz = # memcpy(buffer, xyz, "ABCD");
''''
but after cmpilation, i get this error:
" error: 'xyz' undeclared (first use in this function)"
but it is already declared.
Comments
-
This code is not valid. memcpy takes three arguments:
void *memcpy(void *dest, void *src, size_t count);You have a string literal for the third argument, instead of the count of number of bytes to copy.
Also, what platform and compiler are you using?
1 -
Yeah, i was wrong it is
memcpy(buffer, xyz, 5);
I am in Linux and using gcc version 4.8.50 -
the question is xyz is declared but i am getting undeclared error for it in line memecpy.
0 -
I cannot reproduce this behavior with the information that you've given me so far.
Please contact our technical support department, ([email protected]). Please include a small, compile-able test-case which reproduces this behavior.This is my test-case:
#include <string.h>
static void ABC (unsigned char *buffer, int buffer_size, int num)
{
memset(buffer, '\0', buffer_size);
void *xyz = #
memcpy(buffer, xyz, 5);
}This compiles just fine with insure.
1 -
I compiled your test case and I got this error:
error: 'xyz' undeclared (first use in this function)
void *xyz = #0 -
Hi @shajabedi ,
I could confirm, the test case that @Rich provided compiled just fine with Insure++. I suspect someting wrong with either your setup or environment.
As @Rich wrote, please, create reproducible test case that compiles with your compiler and reproduces the error, and contact our technical support.0