This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Code Composer Error #552-D

Other Parts Discussed in Thread: MSP430G2553

I am using a LaunchPad with a MSP430G2553 and Code Composer 5.5.  I continually get a error about a variable being declared, but unused, even though the variable is used on the next line of code.  

I have simplified my code in an attempt to locate the error.  Any help is appreciated!!

#include <msp430.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void)
{

const char str[] = "4321";
int value = -1;

value = atoi(str);
}

Error Received
#552-D variable "value" was set but never used

 

  • Hello,
    I see that you are setting "value" to the return value of atoi(str). But I don't see where "value" is actually used. Setting a variable to a value is not the same as "using" it.

    stackoverflow.com/.../variable-warning-set-but-not-used

    Thanks
    ki
  • Here is the actual code I am trying to make work. Value is supposed to be given in the atoi conversion in the last few lines. Messages[2] is equal to 1, but the atoi does not occur.

    Thanks,
    Bernard

    #include <msp430.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>

    signed int SplitString(char[]);

    int main(void)
    {
    char str[] = "SBDI +SBDI: 1, 811, 0, 0, 0, 1";
    signed int stringValue = -1;

    stringValue = SplitString(str);

    }

    signed int SplitString(char str[])
    {
    char *token;
    const char delimiter[] = {" :,\r\n"};
    const char *messages[10];

    unsigned int count = 0;
    signed int value = 0;

    for( token = strtok(str, delimiter); token; token = strtok(NULL, delimiter))
    {
    messages[count] = strdup(token);
    count++;
    }
    value = atoi(messages[2]);
    if(value == 1)
    {
    count++;
    }
    return value;
    }
  • when I compile the above code, I get a warning about 'stringValue', not 'value'. Did you mean 'stringValue'?