Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1077
  • Last Modified:

Problem with memcpy function

I get a compilation error with the following code>

C code:

char jobname[10];      
                  memcpy(jobname, "          ", 10);  /* this is line 131 */

Compilation errors:

GC99999/C(STATUS), 131.51: CZM0046(30) Syntax error.                      
GC99999/C(STATUS), 131.19: CZM0182(30) Arguments missing for built-in function __memcpy.                                                      
GC99999/C(STATUS), 131.19: CZM0277(30) Syntax error: possible missing ';' or ','?

I have used the same code in another program with no problem.
0
jc31415
Asked:
jc31415
  • 3
  • 3
  • 2
  • +2
1 Solution
 
PaulCaswellCommented:
Hi jc31415,

Have you got:

#include <memory>

?

Paul
0
 
Harisha M GCommented:
Hi, it is not giving me any errors. Can you post some more code (before that line) ?

---
Harish
0
 
Harisha M GCommented:
Paul, it works with

#include <string.h>

as well :)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Harisha M GCommented:
or.. the C++ <cstring>
0
 
PaulCaswellCommented:
Hi Harish,

Assuming there are no syntax errors prior to these lines I was guessing perhaps memcpy is undefined (lacking the header) but the undefined'edness would also be reported.

I'd guess 'memcpy' has been #defined incorrectly somewhere seems to me to be the next most likely option but it is distinctly rarer.

Lets see what JC has to say :-)

Paul
0
 
jc31415Author Commented:
Since I got the following error message the memcpy function is defined; it just says I have missing arguments.
       
GC99999/C(STATUS), 131.19: CZM0182(30) Arguments missing for built-in function __memcpy.

Also the next statement is:  
   
  memcpy(prtfil, (((var_record_t *)\
       lstptr2)->Data_Field),
       (((Qus_LSPL_Key_Info_t *)lstptr2)\
        ->Data_Length));  

and it doesn't get a compilation error.
0
 
cwwkieCommented:
if you comment out the line with the syntax error, does the compiler error disapear too?
0
 
jc31415Author Commented:
Actually when I recompiled after commenting out the line in error, the next reference to memcpy got the same error. When I commented out all references to memcpy I got no compilation errors.
0
 
PaulCaswellCommented:
Search for all references to 'memcpy' or '_memcpy' or '__memcpy' and see if any of them might specify the wrong number of parameters.

Paul
0
 
Infinity08Commented:
Try this simple program :

----------
#include <stdlib.h>

int main(void) {
  char test[10];
  memcpy((void*) &test[0], (const void*) "test", (size_t) 5);
  memcpy(&test[0], "test", 5);
  memcpy(test, "test", 5);
  return 0;
}
----------

And see if, and at what line the compiler gives an error.

If it doesn't give an error at all, then check whether you correctly included the header file containing the declaration of memcpy(void*, const void*, size_t), AND that there's no re-declaration of memcpy anywhere !!!

If there is a compiler error at one of the above lines, then change your code to match the last correct line's syntax.

If the first line in the above code also provokes a compiler error, then you might want to check if the standard library hasn't been corrupted somehow. What compiler are you using ?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now