Showing results for 
Search instead for 
Did you mean: 

Assign a variable to the c-file line number.

Mike xx
Associate III

I have a FreeRTOS queue with many calls from various tasks.

I would like to assign elements of a variable that is passed into the queue with the file name and line number of the task that is placing the variable on the queue.

I have a corruption issue that might be a stack or perhaps an array that is being sent to the queue that is not copied but sent as a reference?

At the moment I have started to hand code the line numbers, but it's not ideal.

Can anyone help?


Accepted Solutions
Andrew Neil
Evangelist III
Andrew Neil
Evangelist III

__FILE__ and __LINE__



GCC also provides __FILE_NAME__ to give just the name, without path:

Mike xx
Associate III

Many thanks for the quick reply.

My previous google searched had failed me. I hadn't search with gnu or gcc.

I thought they must exist as they do for the IAR compiler.

You're welcome.

Yes, they are part of the C Standard - apart from __FILE_NAME__

If that's answered the question, please mark the solution.