Skip to main content
Ofer
Associate III
May 10, 2026
Question

MCSDK compilation error

  • May 10, 2026
  • 3 replies
  • 190 views

hi,

I created a project by the MCSDK, i tried running it as a C++ project, but im getting an error compilation that i cant solve:

 

../../MCSDK_v6.4.2-Full/MotorControl/MCSDK/MCLib/Any/Inc/revup_ctrl.h: In function 'void RUC_Stop(RevUpCtrl_Handle_t*)':

../../Inc/mc_type.h:77:32: error: invalid conversion from 'void*' to 'RevUpCtrl_PhaseParams_t*' [-fpermissive]

77 | #define MC_NULL (void *)(0x0)

| ^

| |

| void*

 

 

it seems that there is a wrong casting issue.

I tried to solve it in some fifferent wauys like:

pHandle->pCurrentPhaseParams = (RevUpCtrl_PhaseParams_t*)(malloc(MC_NULL));

or

pHandle->pCurrentPhaseParams = static_cast<RevUpCtrl_PhaseParams_t *>malloc(sizeof(MC_NULL));

 

but its not solving the issue.

but when i tried to delete this line it keeps having the same error !!!!!!

what could be the problem

3 replies

Associate II
May 10, 2026

> but when i tried to delete this line it keeps having the same error !!!!!!

 

When you remove the line and the error remains then the problem will be somewhere else.

Maybe the line(s) before.

 

You should provide some more info...

Ofer
OferAuthor
Associate III
May 10, 2026

this is the function which the error happen inside of it:

at the line:

pHandle->pCurrentPhaseParams = MC_NULL;

/**

* @brief Allow to exit from Rev-Up process at the current rotor speed.

* @PAram pHandle: Pointer on Handle structure of RevUp controller.

*/

static inline void RUC_Stop(RevUpCtrl_Handle_t *pHandle)

{

#ifdef NULL_PTR_CHECK_REV_UP_CTL

if (MC_NULL == pHandle)

{

/* Nothing to do */

}

else

{

#endif

VirtualSpeedSensor_Handle_t *pVSS = pHandle->pVSS;

pHandle->pCurrentPhaseParams = MC_NULL;

pHandle->hPhaseRemainingTicks = 0U;

VSS_SetMecAcceleration(pVSS, SPD_GetAvrgMecSpeedUnit(&pVSS->_Super), 0U);

#ifdef NULL_PTR_CHECK_REV_UP_CTL

}

#endif

 

Associate II
May 10, 2026

Maybe it helps to change the line to:

pHandle->pCurrentPhaseParams = (RevUpCtrl_PhaseParams_t *)MC_NULL;
Associate II
May 11, 2026

A note on this:  The correct way to use a null ptr in C++ is null_ptr.

 

In C NULL is defined like your MC_NULL, e.g. as ((void*)0).

In C++ implicit conversion from void* to another pointer is not allowed and because of this NULL is not a pointer, but an int 0. Your definition of MC_NULL is still void*, which causes your problem.

 

I don't know if you can change the definition of MC_NULL. If yes, you can change it like this:

#ifdef __cplusplus
#define MC_NULL null_ptr
#else
#define MC_NULL ((void*)0)
#endif // def __cplusplus

After this you can write things like  pHandle->pCurrentPhaseParams = MC_NULL; in C++ (and in C).

 

If you can not change MC_NULL you can use pHandle->pCurrentPhaseParams = null_ptr; or define an additional MC_NULL_PP as null_ptr and use it in your C++ code like pHandle->pCurrentPhaseParams = MC_NULL_PP;

Ofer
OferAuthor
Associate III
May 13, 2026

thank you for your answers but it seems a much bigger problem.

I got this code generated by the MCSDK for motor cntrol, and any change im doing at this code

doesnt change the compilation results. i tried to clean the project, but it keeps happening