Sysmon example get started compiling error

Hi,

Description

I am trying to compile the sysmon example, but the compiler are presenting a error/warning-error.

sysmon.c: In function ‘sysmon_task’.
error: passing argument 1 to restrict-qualified parameter aliases with argument 3 [-Werror=restrict]
sprintf(buf_long, “%s"LV_TXT_COLOR_CMD”%s MEMORY: %d %%“LV_TXT_COLOR_CMD”\n"
^~~~~~~~

I think the problem are in sprintf below, where the “buf_long” are used twice.

sprintf(buf_long, “%s"LV_TXT_COLOR_CMD”%s MEMORY: %d %%“LV_TXT_COLOR_CMD”\n"
“Total: %d bytes\n”
“Used: %d bytes\n”
“Free: %d bytes\n”
“Frag: %d %%”,
buf_long,
MEM_LABEL_COLOR,
mem_used_pct,
(int)mem_mon.total_size,
(int)mem_mon.total_size - mem_mon.free_size, mem_mon.free_size, mem_mon.frag_pct);

What MCU/Processor/Board and compiler are you using?

Esp32.

What do you want to achieve?

Run the example.

What have you tried so far?

I am trying to compile the example.

Code to reproduce

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "driver/gpio.h"
#include "esp_freertos_hooks.h"

#include "lvgl.h"


//#include "demo.h"
#include "sysmon.h"


#include "disp_spi.h"
#include "ili9341.h"     
#include "tp_spi.h"
#include "xpt2046.h"    

static void IRAM_ATTR lv_tick_task(void);


void app_main()
{
	lv_init();

	disp_spi_init();
	ili9341_init();

	tp_spi_init();
    xpt2046_init();

    static lv_color_t buf1[DISP_BUF_SIZE];
    static lv_color_t buf2[DISP_BUF_SIZE];
    static lv_disp_buf_t disp_buf;
    lv_disp_buf_init(&disp_buf, buf1, buf2, DISP_BUF_SIZE);

	lv_disp_drv_t disp_drv;
	lv_disp_drv_init(&disp_drv);
	disp_drv.flush_cb = ili9341_flush;
	disp_drv.buffer = &disp_buf;
	lv_disp_drv_register(&disp_drv);

    
	
	//Set TOUCH_SUPPORT on drv\component.mk to 1 if
    //your board have touch support
    //#if ENABLE_TOUCH_INPUT
    lv_indev_drv_t indev_drv;
    lv_indev_drv_init(&indev_drv);
    indev_drv.read_cb = xpt2046_read;
    indev_drv.type = LV_INDEV_TYPE_POINTER;
    lv_indev_drv_register(&indev_drv);
	//#endif
	


	esp_register_freertos_tick_hook(lv_tick_task);

	
	//demo_create();
	sysmon_create();
	

	while(1)
    {
		vTaskDelay(1);
		lv_task_handler();		
	}
}

////////////////////////////////////////////////////////
////////////////////////////////////////////////////////

static void IRAM_ATTR lv_tick_task(void)
{
	lv_tick_inc(portTICK_RATE_MS);
}

////////////////////////////////////////////////////////
////////////////////////////////////////////////////////

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Thank’s for the help.

Nice catch; this is not the way s(n)printf should be used.

I will fix it when I get a chance.

Sometimes I use it intentionally to concatenate to the string. Good to know it is not valid. :sweat_smile:

It’s still on my list; I just haven’t gotten around to it yet. Lots of other stuff happening.

1 Like

I’ve fixed it now: https://github.com/littlevgl/lv_examples/commit/11a7dab9db09fff009ed4676320e4a0403a2e589

1 Like