This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

do-while macro expansion error APP_SCHED_INIT

In following this example: https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/scheduler-tutorial

once I added

APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);

The following error results:

3> Compiling ‘main.c’
3> In file included from D:\Current Work\BLE\nRF5_SDK_15.2.0_9412b96\examples\peripheral\nrf5-scheduler-tutorial\main.c:52:
3> ../../../../../../components/libraries/scheduler/app_scheduler.h:118:5: error: expected identifier or '(' before 'do'
3> D:\Current Work\BLE\nRF5_SDK_15.2.0_9412b96\examples\peripheral\nrf5-scheduler-tutorial\main.c:58:1: note: in expansion of macro 'APP_SCHED_INIT'
3> ../../../../../../components/libraries/scheduler/app_scheduler.h:124:7: error: expected identifier or '(' before 'while'
3> D:\Current Work\BLE\nRF5_SDK_15.2.0_9412b96\examples\peripheral\nrf5-scheduler-tutorial\main.c:58:1: note: in expansion of macro 'APP_SCHED_INIT'
Build failed

I followed the tutorial, but I can't seem to get rid of this error.

Parents
  • Hi,

    Based on the error it seems like you put the call to APP_SCHED_INIT() outside a function. The tutorial states you should write the line with the call to APP_SCHED_INIT() "above your main loop", which is not to be confused with above your main function. To be clear, your main function should look like the following after that step:

    int main(void)
    {
        lfclk_request();
        log_init();
        gpio_init();
        timer_init();
    
        NRF_LOG_INFO("Scheduler tutorial example started.");
    
        APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
    
        // Enter main loop.
        while (true)
        {
            __WFI();
        }
    }

Reply
  • Hi,

    Based on the error it seems like you put the call to APP_SCHED_INIT() outside a function. The tutorial states you should write the line with the call to APP_SCHED_INIT() "above your main loop", which is not to be confused with above your main function. To be clear, your main function should look like the following after that step:

    int main(void)
    {
        lfclk_request();
        log_init();
        gpio_init();
        timer_init();
    
        NRF_LOG_INFO("Scheduler tutorial example started.");
    
        APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
    
        // Enter main loop.
        while (true)
        {
            __WFI();
        }
    }

Children
No Data
Related