# Preprocessor \_\_FILE\_\_ for Debugging

**URL:** <https://community.unix.com/t/preprocessor-file-for-debugging/295730>\
**Category:** Programming\
**Created:** [September 21, 2011, 5:26am UTC](https://community.unix.com/t/preprocessor-file-for-debugging/295730 "2011-09-21T05:26:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanlccc](https://community.unix.com/letter_avatar/tanlccc/32/5_5575768a8748004e209b776fc1b2916d.png) [@tanlccc](https://community.unix.com/u/tanlccc)\
**Post date:** [September 21, 2011, 5:26am UTC](https://community.unix.com/t/preprocessor-file-for-debugging/295730/1 "2011-09-21T05:26:30Z")

</div>

Hi,

Just wondering if it is possible to trim the file path output by \_\_FILE\_\_ preprocessor in my debugging line.

Let's say my main.cpp file is found in C:\User\MyName\SystemA\Mod1\SubMod2\Test\main.cpp

for \_\_FILE\_\_, I just want the filename - main.cpp to be printed, instead of the entire path + filename.

---

<div class="post-metadata">

**Author:** ![frank\_rizzo](https://community.unix.com/letter_avatar/frank_rizzo/32/5_5575768a8748004e209b776fc1b2916d.png) [@frank\_rizzo](https://community.unix.com/u/frank_rizzo)\
**Post date:** [September 21, 2011, 7:20am UTC](https://community.unix.com/t/preprocessor-file-for-debugging/295730/2 "2011-09-21T07:20:18Z")

</div>

see [Man Page for basename (Linux Section 3) - The UNIX and Linux Forums](http://www.unix.com/man-page/Linux/3/basename)

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/5_5575768a8748004e209b776fc1b2916d.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [September 21, 2011, 1:32pm UTC](https://community.unix.com/t/preprocessor-file-for-debugging/295730/3 "2011-09-21T13:32:28Z")

</div>

That won't work inside C, frank\_rizzo.

There's not another predefined variable for the name minus path, but you can 'cheat' by altering it with a [#line directive](http://gcc.gnu.org/onlinedocs/cpp/Line-Control.html#Line-Control):

```plaintext
#line 1 "filename.c"
// rest of file

```
