0

I want to make a string value that contains current source file name (__FILE__ without directories) and can be transferred into a debug output method.

I tried the following inline function:

inline string GetFileWithoutDir() {
    path p(__FILE__);
    return p.filename().string();
}

But inline is not guaranteed to be expanded, so __FILE__ may not be the caller's source file, right?

Macros are guaranteed to be expanded, but GetFileWithoutDir has multiple statements. How can I fit these two lines into a single macro?

landings
  • 686
  • 1
  • 8
  • 25
  • 1
    `inline` doesn't do what you seem to think it does – StoryTeller - Unslander Monica Jan 11 '18 at 07:44
  • 1
    `__FILE__` is the file containing the function's definition. It's not the name of the file that's the "root" of the current translation unit or the file that's including the definition. And `inline` ain't got nothing to do with function inlining no more. – molbdnilo Jan 11 '18 at 07:55

0 Answers0