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.

CCS/TM4C123GH6PM: Passing a NULL pointer to MPU6050Init

Part Number: TM4C123GH6PM


Tool/software: Code Composer Studio

Hello,

I want to pass a NULL pointer to the MPU6050Init function.

I've included stddef.h and this is how I declare the NULL pointer:

tSensorCallback *p = NULL;

Afterwards, I use it inside the MPU6050Init as follows:

MPU6050Init(&g_sMPU6050Inst, &g_sI2CInst, MPU6050_I2C_ADDRESS, &p , &g_sMPU6050Inst);

The code compiles but I get the following warning:

Description Resource Path Location Type
#169-D argument of type "tSensorCallback **" is incompatible with parameter of type "tSensorCallback *" main.c

What am I doing wrong? 

  • Hello Shai,

    The way you have used the argument makes your pointer into a double pointer type which isn't compatible with the single pointer parameter. Since your pointer is already declared as a pointer, you shouldn't need the & operator in front of it. The & is used for all the other parameters because they are not declared a pointer to begin with, so the & operator is required for the function to get the memory location information for each of them.