Linked Questions
28 questions linked to/from __FILE__ macro shows full path
0
votes
0
answers
59
views
How to handle source dir paths introduced by __FILE__ in cmake? [duplicate]
I'm using the __FILE__ macro in my main.cpp file. When compiling with make + Makefile the final executable main contains the string main.cpp (you can check it via strings main | grep "*.cpp"...
113
votes
10
answers
274k
views
How do I print to the debug output window in a Win32 app?
I've got a win32 project that I've loaded into Visual Studio 2005. I'd like to be able to print things to the Visual Studio output window, but I can't for the life of me work out how. I've tried '...
25
votes
9
answers
16k
views
__FILE__ macro manipulation handling at compile time
One of the issues I have had in porting some stuff from Solaris to Linux is that the Solaris compiler expands the macro __FILE__ during preprocessing to the file name (e.g. MyFile.cpp) whereas gcc on ...
36
votes
7
answers
36k
views
How to extract the source filename without path and suffix at compile time?
Using both gcc with -std=c11 and g++ with -std=c++14.
E.g. for a file named src/dir/Hello.cxx it should expand to something like e.g.:
const char basename[] = "Hello";
or
const char basename[] = ...
8
votes
7
answers
13k
views
Is there a TRACE statement for basic win32 C++?
In MFC C++ (Visual Studio 6) I am used to using the TRACE macro for debugging. Is there an equivalent statement for plain win32?
7
votes
1
answer
6k
views
Using -ffile-prefix-map breaks debugging
At $DAYJOB, I am trying to implement reproducible builds to make debugging released software where we no longer have the full debug versions on our build servers easier, using the tips from ...
5
votes
4
answers
4k
views
Cpp preprocessor and basename of filename, line number as string
I'd like to produce a static string of the form "example.cpp:34" with the preprocessor, but the __FILE__ macro will expand to "lib/example/example.cpp" and __LINE__ expands to 34 as an integer. Can I ...
1
vote
1
answer
5k
views
__FILE__ not giving full path
If I do this below:
#include <stdio.h>
int main()
{
printf ("%s\n",__FILE__);
return 0;
}
>gcc cfilename.c
>./a.out
>cfilename.c
>pwd
>/home/tek/cpp
> gcc -v
> gcc ...
0
votes
2
answers
3k
views
base file name from __FILE__
I need the file name only where the __FILE__ and __FILEW__ macros return the whole path.
I defined the following:
#define __FILE_NAME_ONLY__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : ...
1
vote
2
answers
3k
views
how to print just filename without using __FILE__ in C [duplicate]
I want to print the filename that is being used in my project.
But if I use __FILE__, it prints entire path along with the file name which is long in my case and disturbs the log indents.
Can anyone ...
0
votes
2
answers
1k
views
is it possible to use the preprocessor __file__ to generate a #define in C?
In order to improve the aesthetics of some code, I would like to have a .h file contain some code that sets a #define based on which file the .h file is included from. For example
#if (__file__ == "...
0
votes
2
answers
2k
views
CMake C/C++ macro generating [duplicate]
I use __FILE__ during logging and debug my program. And when I use it, I get full source file path. So, I wanna write my own macro similar the macro __FILE__.
I looked for a solution, but I found ...
0
votes
2
answers
2k
views
How to get the path where the library is installed
I am working in Linux and I have a library written in Fortran 90 (written by 3rd party), that is reading from a file in the current working directory. I would like to be able to call the resulting ...
2
votes
1
answer
2k
views
Relative path for __FILE__ and PDB
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 ...
5
votes
0
answers
3k
views
C++ __FILE__ macro with absolute path
I am trying to get the absolute path of the compiled file at compile time in C++. I am aware of the __FILE__ macro - however, the macro can be evaluated to either absolute path, or a relative path, ...