Extracting file name from __FILE__

Am I the only one not having trouble with this 'solution': filename extraction from __FILE__ ?

I looks like someone copied a solution for Mac OS, where the path names use slashes instead of backslashes, and replaced the /'s with 's. Sadly this does not work on my Windows 10 laptop, with a compiling error saying " stray \ " etc.

Solution found, however: just use double backslashes:

#define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)

Works like a charm.
Hope this was helpful.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.