0

In the aData.h file I have

struct AnalysisData

{

    Myuint64 maxRegsNeeded; 
}
static const Myuint64 My_NA_Value_64 = (Myuint64) - 1;

Myuint64 is defined in the following way :

typedef unsigned long long Myuint64

If in the aData.cpp file I make :

AnalysisData d;
d.maxRegsNeeded = My_NA_Value_64;

It works ok. but if in the aData.cpp I implement the function

setData(void* pD,size_t s)
{
memcpy(pD,&My_NA_Value_64 ,s);
}

if I implement that as :

setData(void* pD,size_t s)
    {
    Myuint 64 err = My_NA_Value_64;
    memcpy(pD,&err ,s);
    }

it is OK The following code fails during the compilation,with undefined reference to My_NA_Value_64 :

AnalysisData d;
setData(&d.maxRegsNeeded,sizeof(d.maxRegsNeeded));

What is the reason for that?And how can it be solved?

YAKOVM
  • 9,805
  • 31
  • 116
  • 217
  • It [works for me](http://ideone.com/PoCU1V) when I make a self-contained program from your code fragments. Perhaps you could provide a complete, compilable program that demonstrates the problem? – Mike Seymour Jan 21 '13 at 15:37
  • Pick a `setData()`. You have 2 listed here and don't specify which is causing the error, saying *both* are "OK". Please remove what is *not* in your code. I *think* you're trying to say the first one fails the second one works. Also, you have only two files mentioned here, `aData.h` and `aData.cpp`. Consolidate the issue to two snippets. Finally, just for clarity, the failure is likely in the *link* phase; not compilation. – WhozCraig Jan 21 '13 at 15:38
  • 1
    1) Can you provide a minimal compilable example that demonstrates the problem. 2) Can we have the exact error message generated by the compiler. – Martin York Jan 21 '13 at 15:51

0 Answers0