Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ get the line which call a function

#include <iostream>
#include <source_location>
 
void foo(const std::source_location &location = std::source_location::current())
{
    std::cout << location.file_name() << ":"
            << location.line() << ":"
            << location.function_name();
}
 
int main()
{
    foo();
    return 0;
}

// main.cpp:13:int main()
Source by www.techiedelight.com #
 
PREVIOUS NEXT
Tagged: #line #call #function
ADD COMMENT
Topic
Name
9+5 =