Relative path for __FILE__ and PDB
Asked Answered
I

1

2

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
Iceskate answered 30/3, 2020 at 11:39 Comment(7)
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.Scantling
Looks like a duplicate of thisLuhey
duplicates: How do I configure MSVC to show relative path for header files using __FILE__?, __FILE__ macro shows full path, C++ __FILE__ macro with absolute pathSomato
No, sorry, I need MSVC solution.Iceskate
there are many Windows and MSVC solutions in the other questionSomato
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.Iceskate
Besides, use /PDBALTPATH:%_PDB% to hide the absolute path to the PDB file in the executable. See https://mcmap.net/q/517703/-remove-pdb-references-from-released-fileUnaccomplished
P
3

Compile your program without /FC and /ZI options.

Perfectionism answered 30/3, 2020 at 11:47 Comment(2)
Nice. But there will still be an absolute path to the PDB if you look into the target binary.Unaccomplished
@WildernessRanger you might want to use that: learn.microsoft.com/en-us/cpp/build/reference/…Leavening

© 2022 - 2024 — McMap. All rights reserved.