Skip to content

Latest commit

 

History

History
55 lines (43 loc) · 1.04 KB

File metadata and controls

55 lines (43 loc) · 1.04 KB
title __func__ | Microsoft Docs
ms.custom
ms.date 10/19/2017
ms.technology
cpp-language
ms.topic language-reference
f1_keywords
__func__
dev_langs
C++
ms.assetid a5299b8d-f0ee-4af2-91dd-8fb165e68798
author mikeblome
ms.author mblome
ms.workload
cplusplus

func

(C++11) The predefined identifier __func__ is implicitly defined as a string that contains the unqualified and unadorned name of the enclosing function. __func__ is mandated by the C++ standard and is not a Microsoft extension.

Syntax

__func__

Return Value

Returns a null-terminated const char array of characters that contains the function name.

Example

#include <string>
#include <iostream>

namespace Test
{
    struct Foo
    {
        static void DoSomething(int i, std::string s)
        {
           std::cout << __func__ << std::endl; // Output: DoSomething
        }
    };
}

int main()
{
    Test::Foo::DoSomething(42, "Hello");

    return 0;
}

Requirements

C++11