1

I want to hide machine specific path part from executable.

Is it possible to force relative path for PDB symbols and __FILE__ macro?

So that some/all initial parts of path are not put into file?

I use MSVC, GCC solutions will not work.

All options are following:

/permissive- /MP /GS /Zc:rvalueCast /analyze- /W3 /Zc:wchar_t /I"
<some path here>" /Qspectre-load /ZI /Gm- /Od /sdl /Fd"<some path here>"
/Zc:inline /fp:precise /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D
"_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1
/GR- /Gd /Oy- /MTd /openmp- /Fa"<some path here>" /EHa /nologo
/Fo"<some path here>" /Fp"<some path here>" /diagnostics:classic
Reinier Torenbeek
  • 15,354
  • 6
  • 39
  • 61
adontz
  • 1,368
  • 15
  • 33
  • I don't know about VS, so I don't know if the behaviour of the macro can be configured. But instead of doing that, you can remove the parent path at runtime. – eerorika Mar 30 '20 at 11:45
  • Looks like a duplicate of [this](https://stackoverflow.com/questions/8487986/file-macro-shows-full-path) – Ryan Pepper Mar 30 '20 at 11:46
  • duplicates: [How do I configure MSVC to show relative path for header files using `__FILE__`?](https://stackoverflow.com/q/41567178/995714), [`__FILE__` macro shows full path](https://stackoverflow.com/q/8487986/995714), [C++ `__FILE__` macro with absolute path](https://stackoverflow.com/q/50124235/995714) – phuclv Mar 30 '20 at 11:47
  • Does this answer your question? [\_\_FILE\_\_ macro shows full path](https://stackoverflow.com/questions/8487986/file-macro-shows-full-path) – phuclv Mar 30 '20 at 11:47
  • No, sorry, I need MSVC solution. – adontz Mar 30 '20 at 13:51
  • there are many Windows and MSVC solutions in the other question – phuclv Mar 30 '20 at 16:42
  • The question is not how to extract base name from file path. The question is how to prevent full path from compiled executable in the first place. – adontz Mar 30 '20 at 19:24

1 Answers1

1

Compile your program without /FC and /ZI options.

Öö Tiib
  • 10,226
  • 24
  • 40
  • Does not seem to work. Here are all options. /permissive- /MP /GS /Zc:rvalueCast /analyze- /W3 /Zc:wchar_t /I"" /Qspectre-load /ZI /Gm- /Od /sdl /Fd"" /Zc:inline /fp:precise /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /GR- /Gd /Oy- /MTd /openmp- /Fa"" /EHa /nologo /Fo"" /Fp"" /diagnostics:classic – adontz Mar 30 '20 at 12:03
  • Isn't there /ZI in it? I somehow see it. – Öö Tiib Mar 30 '20 at 12:07
  • /permissive- /MP /GS /Zc:rvalueCast /analyze- /W3 /Zc:wchar_t /I"" /Qspectre-load /Gm- /Od /sdl /Fd"D:\Users\Adontz\Projects\VS2019\win-scone\intermediates\x86\debug\server-print-service\vc142.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /GR- /Gd /Oy- /MTd /openmp- /Fa"" /EHa /nologo /Fo"" /Fp"" /diagnostics:classic Does not work either, still full path in \__FILE__ – adontz Mar 30 '20 at 13:50
  • Looks like it took effect after a few recompilations :-( – adontz Mar 30 '20 at 20:34