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.

how to declare a pointer in a function



I have a error when I compile the program. the error is: #161 declaration is incompatible with previous "I2C_write_data" (declared at line 114)

the program is:

int main (void)

{

char data_read_write [3] = {0,12,0};

char err = 0;

err = I2C_write_data(3,data_read_write,0x40};

...

}

int I2C_write_data(char nb_write, char* data_write, char adress)

{

...

}

  • micou, 

    you need to have a declaration of  the I2C_write_data() function before using it in main().

    Do you include the declaration in any header files included at the beginning of the code?

    If not, just declare it like this:

    // function declaration
    int I2C_write_data(char nb_write, char* data_write, char adress);
    
    
    int main (void)
    {
    
      char data_read_write [3] = {0,12,0};
    
      char err = 0;
    
      err = I2C_write_data(3,data_read_write,0x40};
    
      ...
    }
    
    int I2C_write_data(char nb_write, char* data_write, char adress)
    {
    
    ...
    
    }
  • micou ludovic said:
    the error is: #161 declaration is incompatible with previous "I2C_write_data" (declared at line 114)

    What else errors or warnings do you get?
    There must be some.

    Especially since:

    micou ludovic said:
    err = I2C_write_data(3,data_read_write,0x40};
    the closing bracket is of the wrong type.

**Attention** This is a public forum