Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Full path names printed for __FILE__ in VS2008

Our code uses __FILE__ to print code locations in a log file.
Our intent is for all instances of __FILE__ to print the filename ONLY, no path.

However, we just noticed that while source (.cpp files) correctly print just the filename, the headers (.h files) print the full path. This exposes our build server's path on customer installations, which is confusing at best.

I have researched the /FC (full pathnames) compile option and how it relates to the /ZI and /Zi (debug info generation) compile options. Short version - /ZI implies /FC. We are currently using /Zi, but we are not using either /ZI or /FC, so we should be fine.

We are using a project-wide precompiled header (PCH), but none of the headers included in the PCH use __FILE__, so that seems irrelevant.

What's going on here?
Is there possibly a latent compile option I'm triggering?
Does anyone know of a workaround that doesn't involve calling run-time string manipulation functions?

like image 646
mskfisher Avatar asked Nov 14 '22 02:11

mskfisher


1 Answers

This is asserted as "by design" in this feedback article. Consider a post-processing step that hacks the paths the way you want them.

like image 92
Hans Passant Avatar answered Dec 18 '22 00:12

Hans Passant