Skip to content

Instantly share code, notes, and snippets.

@jflopezfernandez
Created November 6, 2018 19:33
Show Gist options
  • Save jflopezfernandez/896e2f61c36a908d7824b1a0fed08c91 to your computer and use it in GitHub Desktop.
Save jflopezfernandez/896e2f61c36a908d7824b1a0fed08c91 to your computer and use it in GitHub Desktop.
MSVC - Print current function to log
// ---------------------------------------------------------------------------------------------------------
//
// Author: Jose Fernando Lopez Fernandez
// Date: 6-November-2018
//
// Description: Logs the current function to std::clog. Simple inline function won't work for obvious reasons,
// so this is a workaround to not have to fire up the actual debugger and check the call stack.
// The function call format is for homogeneity in the code, while preventing confusion by explicitly
// including the fact that it is a macro in the name.
//
// Usage:
// void DoSomething() {
// LogFunctionNameMacro();
// Do things...
// }
//
// Output:
// Calling function: DoSomething
//
// ---------------------------------------------------------------------------------------------------------
#define LogFunctionNameMacro() (std::clog << "Calling function: " << __FUNCTION__ << '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment