Search code examples
csyntaxrtoskeil

C function declaration syntax - why does this work?


I have been going through some RTOS example code (a slightly old version of Keil RTX, if anyone's interested) and I came across some syntax I didn't understand:

void job1 (void) __task;
void job2 (void) __task;

This was giving errors (error: #130: expected a "{"), so changed the example code to this:

void __task job1 (void);
void __task job2 (void);

And suddenly the file compiled. I had thought functions declarations were just return type, name, and arguments. What is __task? I haven't been able to find the definition of __task because the project isn't building the map file correctly and I suspect I might also be missing a file.


Solution

  • It's not C, it a Keil compiler extension to C.

    _task keyword tells the compiler not to add the function entry and exit code.

    Read your compiler documentation to get more information.