Хорошо, поэтому я получаю эту ошибку, и я не знаю, как ее исправить: недопустимое преобразование из 'char * * в' char * '
Dong (char *) ulStatsAsPercentage не помогает.
Я получаю эту ошибку в обоих операторах sprintf, в последнем аргументе каждого из них, в ulStatsAsPercentage в первом утверждении sprintf и в pxTaskStatusArray [x] .ulRunTimeCounter во втором утверждении sprintf.
Вот мой код:
TaskStatus_t *pxTaskStatusArray;
volatile UBaseType_t uxArraySize, x;
unsigned long ulTotalRunTime, ulStatsAsPercentage;
ulStatsAsPercentage =
pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;
pxTaskStatusArray = (TaskStatus_t*)pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
if( ulStatsAsPercentage > 0UL )
{
sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n",
pxTaskStatusArray[ x ].pcTaskName,
pxTaskStatusArray[ x ].ulRunTimeCounter,
ulStatsAsPercentage );//error at this line
}
else
{
/* If the percentage is zero here then the task has
consumed less than 1% of the total run time. */
sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\r\n",
pxTaskStatusArray[ x ].pcTaskName,
pxTaskStatusArray[ x ].ulRunTimeCounter );//error here too
}
Вот консоль с ошибками:
../L5_Application/main.cpp:181:60: error: invalid conversion from 'signed char*' to 'char*' [-fpermissive]
(char)ulStatsAsPercentage );
c:\users\alti\downloads\sjsu_dev\toolchain\arm-none-eabi\include\stdio.h:244:5: note: initializing argument 1 of 'int sprintf(char*, const char*, ...)'
int _EXFUN(sprintf, (char *__restrict, const char *__restrict, ...)
^
../L5_Application/main.cpp:181:60: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'int' [-Wformat=]
(char)ulStatsAsPercentage );
^
../L5_Application/main.cpp:181:60: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'int' [-Wformat=]
../L5_Application/main.cpp:189:74: error: invalid conversion from 'signed char*' to 'char*' [-fpermissive]
pxTaskStatusArray[ x ].ulRunTimeCounter );
^
c:\users\alti\downloads\sjsu_dev\toolchain\arm-none-eabi\include\stdio.h:244:5: note: initializing argument 1 of 'int sprintf(char*, const char*, ...)'
int _EXFUN(sprintf, (char *__restrict, const char *__restrict, ...)
^
Любая помощь будет признательна.