cancel
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?

1 ACCEPTED SOLUTION

Accepted Solutions
3 REPLIES 3

__FILE__ and __LINE__

 

https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html

 

EDIT:

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

https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html

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.