0

I am debugging some C++ software, and want to modify an existing function slightly, so that it changes the value of a particular variable used elsewhere in the program.

The function is currently defined as so:

void DataStore::setEraseSelected(){
    ...
    // Function code here
    ...
}

As it stands, the function works correctly with no problems whatsoever. But, I now want to modify the function, so that it will change the value of a variable used elsewhere in the program. To do this, I have tried passing the variable into the function as a parameter (I have also updated the header file to reflect the changes to the function), and then assigning a value to the variable inside the function:

void DataStore::setEraseSelected(toAMS::DataMessage statusMsg){
    ...
    // Function code here
    ...
    statusMsg.CODE_ERASE = Types::Activated;
    ...
}

As mentioned, I have added the declaration to the header file, so that it now has the declaration for the function with the parameter, as well as the one for the function without the parameter:

void DataStore::setEraseSelected(toAMS::DataMessage statusMsg);

But when I try and build the code (using Visual Studio 2010), I get the following two compile errors:

error LNK2001: unresolved external symbol "public void_thiscall DataStore::setEraseSelected(void)" (? setEraseSelected@DataStore::QAEXXZ)

error LNK1120: 1 unresolved externals

The first error highlights the project .obj file, which I have tried deleting and building again, but get the same error, and second one highlights the project .exe file, which I have also tried deleting and building again, but get the same error.

Anyone have any ideas why? I've had a look on SO for questions regarding these errors, but none of them seem to clearly explain why I might be getting them. They all seem to suggest that the compiler is possibly looking in the wrong place, but if I undo my changes, then the code compiles with no problems, and I haven't told the compiler to look anywhere else when building the code with my changes...

Community
  • 1
  • 1
Noble-Surfer
  • 3,052
  • 11
  • 73
  • 118

1 Answers1

0

void DataStore::setEraseSelected(int );

Pass that variable