Linked Questions

0 votes
0 answers
59 views

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"...
cppbest's user avatar
  • 249
113 votes
10 answers
274k views

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 '...
izb's user avatar
  • 52.2k
25 votes
9 answers
16k views

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 ...
ScaryAardvark's user avatar
36 votes
7 answers
36k views

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[] = ...
Joe's user avatar
  • 3,190
8 votes
7 answers
13k views

In MFC C++ (Visual Studio 6) I am used to using the TRACE macro for debugging. Is there an equivalent statement for plain win32?
jacobsee's user avatar
  • 1,508
7 votes
1 answer
6k views

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 ...
nafmo's user avatar
  • 518
5 votes
4 answers
4k views

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 ...
pythonic metaphor's user avatar
1 vote
1 answer
5k views

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 ...
user3317205's user avatar
0 votes
2 answers
3k views

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 : ...
Saher Ahwal's user avatar
  • 9,277
1 vote
2 answers
3k views

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 ...
Madara's user avatar
  • 163
0 votes
2 answers
1k views

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__ == "...
reza's user avatar
  • 1,379
0 votes
2 answers
2k views

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 ...
voltento's user avatar
  • 907
0 votes
2 answers
2k views

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 ...
simona's user avatar
  • 2,211
2 votes
1 answer
2k views

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 ...
adontz's user avatar
  • 1,438
5 votes
0 answers
3k views

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, ...
Michał's user avatar
  • 2,292

15 30 50 per page