How to get c++ function caller name at preprocessing stage
I have to use a macro PERF_INSTRUMENT
from a library. PERF_INSTRUMENT
expects a user provided c-style string as a function name to print the location of this instrument point.
But, I don't want to write the function name everytime I use PERF_INSTRUMENT
instead I want to call it with __func__
so that function name is automatically included in the perf log.
But when I use __func__
it actually returns operator()
because the __func__
is embedded inside the lambda function.
Is their any way by which I can pass the main()
function name to the PERF_INSTRUMENT
macro.
#include <cstdio>
#include <cassert>
#include <type_traits>
using namespace std;
namespace /* anonymous */
{
template< typename T >
struct Is_Const_Char_Array
: std::is_same< std::remove_reference_t< T >,
char const[ std::extent< std::remove_reference_t< T > >::value ] >
{};
template< typename T >
struct Is_C_String_Literal
: Is_Const_Char_Array< T >
{};
}
#define PERF_INSTRUMENT(name) auto instObj = { static_assert( Is_C_String_Literal< decltype( name ) >::value, "input argument must be a c-string literal" ); /* Some other Logic*/ printf(name);return 1; }()
// <------------------ MY CODE -------------------> //
int main(){
PERF_INSTRUMENT("main"); // <-- this works fine
PERF_INSTRUMENT(__func__); // <-- this prints operator()
// PERF_INSTRUMENT(__builtin_FUNCTION());
}
Please Note that I can only change the code below the MY CODE line
c++ c++11 c-preprocessor template-meta-programming preprocessor-meta-program
add a comment |
I have to use a macro PERF_INSTRUMENT
from a library. PERF_INSTRUMENT
expects a user provided c-style string as a function name to print the location of this instrument point.
But, I don't want to write the function name everytime I use PERF_INSTRUMENT
instead I want to call it with __func__
so that function name is automatically included in the perf log.
But when I use __func__
it actually returns operator()
because the __func__
is embedded inside the lambda function.
Is their any way by which I can pass the main()
function name to the PERF_INSTRUMENT
macro.
#include <cstdio>
#include <cassert>
#include <type_traits>
using namespace std;
namespace /* anonymous */
{
template< typename T >
struct Is_Const_Char_Array
: std::is_same< std::remove_reference_t< T >,
char const[ std::extent< std::remove_reference_t< T > >::value ] >
{};
template< typename T >
struct Is_C_String_Literal
: Is_Const_Char_Array< T >
{};
}
#define PERF_INSTRUMENT(name) auto instObj = { static_assert( Is_C_String_Literal< decltype( name ) >::value, "input argument must be a c-string literal" ); /* Some other Logic*/ printf(name);return 1; }()
// <------------------ MY CODE -------------------> //
int main(){
PERF_INSTRUMENT("main"); // <-- this works fine
PERF_INSTRUMENT(__func__); // <-- this prints operator()
// PERF_INSTRUMENT(__builtin_FUNCTION());
}
Please Note that I can only change the code below the MY CODE line
c++ c++11 c-preprocessor template-meta-programming preprocessor-meta-program
why don't you just remove the lambda ? use ado { .... } while(0)
to group your statements
– Xatyrian
Nov 21 '18 at 12:42
__builtin_FUNCTION
(a GNU extension I believe)
– rustyx
Nov 21 '18 at 12:48
...or write the macro such that the calling function name is expanded where you call the macro and the macro passes that as string to the lambda
– user463035818
Nov 21 '18 at 12:49
Was looking for this myself yesterday, depends on compiler, try: __ FUNCTION __ (without spaces)
– SPlatten
Nov 21 '18 at 13:25
1
boys he's saying he's using a macro from a library, so it's likely he can't change it
– Marko Pacak
Nov 21 '18 at 13:58
add a comment |
I have to use a macro PERF_INSTRUMENT
from a library. PERF_INSTRUMENT
expects a user provided c-style string as a function name to print the location of this instrument point.
But, I don't want to write the function name everytime I use PERF_INSTRUMENT
instead I want to call it with __func__
so that function name is automatically included in the perf log.
But when I use __func__
it actually returns operator()
because the __func__
is embedded inside the lambda function.
Is their any way by which I can pass the main()
function name to the PERF_INSTRUMENT
macro.
#include <cstdio>
#include <cassert>
#include <type_traits>
using namespace std;
namespace /* anonymous */
{
template< typename T >
struct Is_Const_Char_Array
: std::is_same< std::remove_reference_t< T >,
char const[ std::extent< std::remove_reference_t< T > >::value ] >
{};
template< typename T >
struct Is_C_String_Literal
: Is_Const_Char_Array< T >
{};
}
#define PERF_INSTRUMENT(name) auto instObj = { static_assert( Is_C_String_Literal< decltype( name ) >::value, "input argument must be a c-string literal" ); /* Some other Logic*/ printf(name);return 1; }()
// <------------------ MY CODE -------------------> //
int main(){
PERF_INSTRUMENT("main"); // <-- this works fine
PERF_INSTRUMENT(__func__); // <-- this prints operator()
// PERF_INSTRUMENT(__builtin_FUNCTION());
}
Please Note that I can only change the code below the MY CODE line
c++ c++11 c-preprocessor template-meta-programming preprocessor-meta-program
I have to use a macro PERF_INSTRUMENT
from a library. PERF_INSTRUMENT
expects a user provided c-style string as a function name to print the location of this instrument point.
But, I don't want to write the function name everytime I use PERF_INSTRUMENT
instead I want to call it with __func__
so that function name is automatically included in the perf log.
But when I use __func__
it actually returns operator()
because the __func__
is embedded inside the lambda function.
Is their any way by which I can pass the main()
function name to the PERF_INSTRUMENT
macro.
#include <cstdio>
#include <cassert>
#include <type_traits>
using namespace std;
namespace /* anonymous */
{
template< typename T >
struct Is_Const_Char_Array
: std::is_same< std::remove_reference_t< T >,
char const[ std::extent< std::remove_reference_t< T > >::value ] >
{};
template< typename T >
struct Is_C_String_Literal
: Is_Const_Char_Array< T >
{};
}
#define PERF_INSTRUMENT(name) auto instObj = { static_assert( Is_C_String_Literal< decltype( name ) >::value, "input argument must be a c-string literal" ); /* Some other Logic*/ printf(name);return 1; }()
// <------------------ MY CODE -------------------> //
int main(){
PERF_INSTRUMENT("main"); // <-- this works fine
PERF_INSTRUMENT(__func__); // <-- this prints operator()
// PERF_INSTRUMENT(__builtin_FUNCTION());
}
Please Note that I can only change the code below the MY CODE line
c++ c++11 c-preprocessor template-meta-programming preprocessor-meta-program
c++ c++11 c-preprocessor template-meta-programming preprocessor-meta-program
edited Nov 22 '18 at 9:42
Mohit
asked Nov 21 '18 at 12:39
MohitMohit
552515
552515
why don't you just remove the lambda ? use ado { .... } while(0)
to group your statements
– Xatyrian
Nov 21 '18 at 12:42
__builtin_FUNCTION
(a GNU extension I believe)
– rustyx
Nov 21 '18 at 12:48
...or write the macro such that the calling function name is expanded where you call the macro and the macro passes that as string to the lambda
– user463035818
Nov 21 '18 at 12:49
Was looking for this myself yesterday, depends on compiler, try: __ FUNCTION __ (without spaces)
– SPlatten
Nov 21 '18 at 13:25
1
boys he's saying he's using a macro from a library, so it's likely he can't change it
– Marko Pacak
Nov 21 '18 at 13:58
add a comment |
why don't you just remove the lambda ? use ado { .... } while(0)
to group your statements
– Xatyrian
Nov 21 '18 at 12:42
__builtin_FUNCTION
(a GNU extension I believe)
– rustyx
Nov 21 '18 at 12:48
...or write the macro such that the calling function name is expanded where you call the macro and the macro passes that as string to the lambda
– user463035818
Nov 21 '18 at 12:49
Was looking for this myself yesterday, depends on compiler, try: __ FUNCTION __ (without spaces)
– SPlatten
Nov 21 '18 at 13:25
1
boys he's saying he's using a macro from a library, so it's likely he can't change it
– Marko Pacak
Nov 21 '18 at 13:58
why don't you just remove the lambda ? use a
do { .... } while(0)
to group your statements– Xatyrian
Nov 21 '18 at 12:42
why don't you just remove the lambda ? use a
do { .... } while(0)
to group your statements– Xatyrian
Nov 21 '18 at 12:42
__builtin_FUNCTION
(a GNU extension I believe)– rustyx
Nov 21 '18 at 12:48
__builtin_FUNCTION
(a GNU extension I believe)– rustyx
Nov 21 '18 at 12:48
...or write the macro such that the calling function name is expanded where you call the macro and the macro passes that as string to the lambda
– user463035818
Nov 21 '18 at 12:49
...or write the macro such that the calling function name is expanded where you call the macro and the macro passes that as string to the lambda
– user463035818
Nov 21 '18 at 12:49
Was looking for this myself yesterday, depends on compiler, try: __ FUNCTION __ (without spaces)
– SPlatten
Nov 21 '18 at 13:25
Was looking for this myself yesterday, depends on compiler, try: __ FUNCTION __ (without spaces)
– SPlatten
Nov 21 '18 at 13:25
1
1
boys he's saying he's using a macro from a library, so it's likely he can't change it
– Marko Pacak
Nov 21 '18 at 13:58
boys he's saying he's using a macro from a library, so it's likely he can't change it
– Marko Pacak
Nov 21 '18 at 13:58
add a comment |
2 Answers
2
active
oldest
votes
Is their any way by which I can pass the main function name to the PERF_INSTRUMENT macro.
You can pass "name
" as argument to the lambda itself.
Something as
#define PERF_INSTRUMENT(name)
auto instObj = (char const * str) // <-- receive an argument
{ static_assert( Is_C_String_Literal< decltype( name ) >::value,
"input argument must be a c-string literal" );
/* Some other Logic*/
printf(str); // <-- print the argument received, not directly name
return 1;
}(name)
//.......^^^^ pass name as argument
Bonus Off Topic proposal: to detect is an object is a C-string literal, i propose an alternative way
template <typename T>
constexpr std::false_type islHelper (T, long);
template <typename T, std::size_t N>
constexpr std::true_type islHelper (T const(&)[N], int);
template <typename T>
using isStringLiteral = decltype(islHelper(std::declval<T>(), 0));
In static_assert()
become
static_assert( isStringLiteral<decltype(name)>::value,
"input argument must be a c-string literal" );
1
That assert isn't very robust. For example,const char s[1]; static_assert(isStringLiteral<decltype(s))>::value, "You won't see this message." );
– molbdnilo
Nov 21 '18 at 14:03
@molbdnilo - Unfortunately you're right. I can solve this problem imposing (through SFINAE) thatN
is greater than1
but I don't know if is the case:char const s { "abc" };
result a string literal but this isn't exactly correct (I suppose).
– max66
Nov 21 '18 at 18:38
The size has nothing to do with it, and yours
is not a string literal. There is no way to distinguish between string literals and otherconst
char arrays.
– molbdnilo
Nov 21 '18 at 18:53
Pls understand that I cannot change thePERF_INSTRUMENT
macro
– Mohit
Nov 26 '18 at 9:06
add a comment |
Since the assert is fundamentally flawed – it accepts any const
char array – wrapping the macro in another macro should work.
Something like this:
#define PERF_FUNCTION do {
const char name = __func__;
PERF_INSTRUMENT(name);
} while(0)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412226%2fhow-to-get-c-function-caller-name-at-preprocessing-stage%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is their any way by which I can pass the main function name to the PERF_INSTRUMENT macro.
You can pass "name
" as argument to the lambda itself.
Something as
#define PERF_INSTRUMENT(name)
auto instObj = (char const * str) // <-- receive an argument
{ static_assert( Is_C_String_Literal< decltype( name ) >::value,
"input argument must be a c-string literal" );
/* Some other Logic*/
printf(str); // <-- print the argument received, not directly name
return 1;
}(name)
//.......^^^^ pass name as argument
Bonus Off Topic proposal: to detect is an object is a C-string literal, i propose an alternative way
template <typename T>
constexpr std::false_type islHelper (T, long);
template <typename T, std::size_t N>
constexpr std::true_type islHelper (T const(&)[N], int);
template <typename T>
using isStringLiteral = decltype(islHelper(std::declval<T>(), 0));
In static_assert()
become
static_assert( isStringLiteral<decltype(name)>::value,
"input argument must be a c-string literal" );
1
That assert isn't very robust. For example,const char s[1]; static_assert(isStringLiteral<decltype(s))>::value, "You won't see this message." );
– molbdnilo
Nov 21 '18 at 14:03
@molbdnilo - Unfortunately you're right. I can solve this problem imposing (through SFINAE) thatN
is greater than1
but I don't know if is the case:char const s { "abc" };
result a string literal but this isn't exactly correct (I suppose).
– max66
Nov 21 '18 at 18:38
The size has nothing to do with it, and yours
is not a string literal. There is no way to distinguish between string literals and otherconst
char arrays.
– molbdnilo
Nov 21 '18 at 18:53
Pls understand that I cannot change thePERF_INSTRUMENT
macro
– Mohit
Nov 26 '18 at 9:06
add a comment |
Is their any way by which I can pass the main function name to the PERF_INSTRUMENT macro.
You can pass "name
" as argument to the lambda itself.
Something as
#define PERF_INSTRUMENT(name)
auto instObj = (char const * str) // <-- receive an argument
{ static_assert( Is_C_String_Literal< decltype( name ) >::value,
"input argument must be a c-string literal" );
/* Some other Logic*/
printf(str); // <-- print the argument received, not directly name
return 1;
}(name)
//.......^^^^ pass name as argument
Bonus Off Topic proposal: to detect is an object is a C-string literal, i propose an alternative way
template <typename T>
constexpr std::false_type islHelper (T, long);
template <typename T, std::size_t N>
constexpr std::true_type islHelper (T const(&)[N], int);
template <typename T>
using isStringLiteral = decltype(islHelper(std::declval<T>(), 0));
In static_assert()
become
static_assert( isStringLiteral<decltype(name)>::value,
"input argument must be a c-string literal" );
1
That assert isn't very robust. For example,const char s[1]; static_assert(isStringLiteral<decltype(s))>::value, "You won't see this message." );
– molbdnilo
Nov 21 '18 at 14:03
@molbdnilo - Unfortunately you're right. I can solve this problem imposing (through SFINAE) thatN
is greater than1
but I don't know if is the case:char const s { "abc" };
result a string literal but this isn't exactly correct (I suppose).
– max66
Nov 21 '18 at 18:38
The size has nothing to do with it, and yours
is not a string literal. There is no way to distinguish between string literals and otherconst
char arrays.
– molbdnilo
Nov 21 '18 at 18:53
Pls understand that I cannot change thePERF_INSTRUMENT
macro
– Mohit
Nov 26 '18 at 9:06
add a comment |
Is their any way by which I can pass the main function name to the PERF_INSTRUMENT macro.
You can pass "name
" as argument to the lambda itself.
Something as
#define PERF_INSTRUMENT(name)
auto instObj = (char const * str) // <-- receive an argument
{ static_assert( Is_C_String_Literal< decltype( name ) >::value,
"input argument must be a c-string literal" );
/* Some other Logic*/
printf(str); // <-- print the argument received, not directly name
return 1;
}(name)
//.......^^^^ pass name as argument
Bonus Off Topic proposal: to detect is an object is a C-string literal, i propose an alternative way
template <typename T>
constexpr std::false_type islHelper (T, long);
template <typename T, std::size_t N>
constexpr std::true_type islHelper (T const(&)[N], int);
template <typename T>
using isStringLiteral = decltype(islHelper(std::declval<T>(), 0));
In static_assert()
become
static_assert( isStringLiteral<decltype(name)>::value,
"input argument must be a c-string literal" );
Is their any way by which I can pass the main function name to the PERF_INSTRUMENT macro.
You can pass "name
" as argument to the lambda itself.
Something as
#define PERF_INSTRUMENT(name)
auto instObj = (char const * str) // <-- receive an argument
{ static_assert( Is_C_String_Literal< decltype( name ) >::value,
"input argument must be a c-string literal" );
/* Some other Logic*/
printf(str); // <-- print the argument received, not directly name
return 1;
}(name)
//.......^^^^ pass name as argument
Bonus Off Topic proposal: to detect is an object is a C-string literal, i propose an alternative way
template <typename T>
constexpr std::false_type islHelper (T, long);
template <typename T, std::size_t N>
constexpr std::true_type islHelper (T const(&)[N], int);
template <typename T>
using isStringLiteral = decltype(islHelper(std::declval<T>(), 0));
In static_assert()
become
static_assert( isStringLiteral<decltype(name)>::value,
"input argument must be a c-string literal" );
edited Nov 21 '18 at 17:17
user463035818
18k42868
18k42868
answered Nov 21 '18 at 13:11
max66max66
38.3k74472
38.3k74472
1
That assert isn't very robust. For example,const char s[1]; static_assert(isStringLiteral<decltype(s))>::value, "You won't see this message." );
– molbdnilo
Nov 21 '18 at 14:03
@molbdnilo - Unfortunately you're right. I can solve this problem imposing (through SFINAE) thatN
is greater than1
but I don't know if is the case:char const s { "abc" };
result a string literal but this isn't exactly correct (I suppose).
– max66
Nov 21 '18 at 18:38
The size has nothing to do with it, and yours
is not a string literal. There is no way to distinguish between string literals and otherconst
char arrays.
– molbdnilo
Nov 21 '18 at 18:53
Pls understand that I cannot change thePERF_INSTRUMENT
macro
– Mohit
Nov 26 '18 at 9:06
add a comment |
1
That assert isn't very robust. For example,const char s[1]; static_assert(isStringLiteral<decltype(s))>::value, "You won't see this message." );
– molbdnilo
Nov 21 '18 at 14:03
@molbdnilo - Unfortunately you're right. I can solve this problem imposing (through SFINAE) thatN
is greater than1
but I don't know if is the case:char const s { "abc" };
result a string literal but this isn't exactly correct (I suppose).
– max66
Nov 21 '18 at 18:38
The size has nothing to do with it, and yours
is not a string literal. There is no way to distinguish between string literals and otherconst
char arrays.
– molbdnilo
Nov 21 '18 at 18:53
Pls understand that I cannot change thePERF_INSTRUMENT
macro
– Mohit
Nov 26 '18 at 9:06
1
1
That assert isn't very robust. For example,
const char s[1]; static_assert(isStringLiteral<decltype(s))>::value, "You won't see this message." );
– molbdnilo
Nov 21 '18 at 14:03
That assert isn't very robust. For example,
const char s[1]; static_assert(isStringLiteral<decltype(s))>::value, "You won't see this message." );
– molbdnilo
Nov 21 '18 at 14:03
@molbdnilo - Unfortunately you're right. I can solve this problem imposing (through SFINAE) that
N
is greater than 1
but I don't know if is the case: char const s { "abc" };
result a string literal but this isn't exactly correct (I suppose).– max66
Nov 21 '18 at 18:38
@molbdnilo - Unfortunately you're right. I can solve this problem imposing (through SFINAE) that
N
is greater than 1
but I don't know if is the case: char const s { "abc" };
result a string literal but this isn't exactly correct (I suppose).– max66
Nov 21 '18 at 18:38
The size has nothing to do with it, and your
s
is not a string literal. There is no way to distinguish between string literals and other const
char arrays.– molbdnilo
Nov 21 '18 at 18:53
The size has nothing to do with it, and your
s
is not a string literal. There is no way to distinguish between string literals and other const
char arrays.– molbdnilo
Nov 21 '18 at 18:53
Pls understand that I cannot change the
PERF_INSTRUMENT
macro– Mohit
Nov 26 '18 at 9:06
Pls understand that I cannot change the
PERF_INSTRUMENT
macro– Mohit
Nov 26 '18 at 9:06
add a comment |
Since the assert is fundamentally flawed – it accepts any const
char array – wrapping the macro in another macro should work.
Something like this:
#define PERF_FUNCTION do {
const char name = __func__;
PERF_INSTRUMENT(name);
} while(0)
add a comment |
Since the assert is fundamentally flawed – it accepts any const
char array – wrapping the macro in another macro should work.
Something like this:
#define PERF_FUNCTION do {
const char name = __func__;
PERF_INSTRUMENT(name);
} while(0)
add a comment |
Since the assert is fundamentally flawed – it accepts any const
char array – wrapping the macro in another macro should work.
Something like this:
#define PERF_FUNCTION do {
const char name = __func__;
PERF_INSTRUMENT(name);
} while(0)
Since the assert is fundamentally flawed – it accepts any const
char array – wrapping the macro in another macro should work.
Something like this:
#define PERF_FUNCTION do {
const char name = __func__;
PERF_INSTRUMENT(name);
} while(0)
edited Nov 21 '18 at 15:22
answered Nov 21 '18 at 15:17
molbdnilomolbdnilo
41.4k32152
41.4k32152
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412226%2fhow-to-get-c-function-caller-name-at-preprocessing-stage%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
why don't you just remove the lambda ? use a
do { .... } while(0)
to group your statements– Xatyrian
Nov 21 '18 at 12:42
__builtin_FUNCTION
(a GNU extension I believe)– rustyx
Nov 21 '18 at 12:48
...or write the macro such that the calling function name is expanded where you call the macro and the macro passes that as string to the lambda
– user463035818
Nov 21 '18 at 12:49
Was looking for this myself yesterday, depends on compiler, try: __ FUNCTION __ (without spaces)
– SPlatten
Nov 21 '18 at 13:25
1
boys he's saying he's using a macro from a library, so it's likely he can't change it
– Marko Pacak
Nov 21 '18 at 13:58