diff --git a/example/example.cpp b/example/example.cpp index 0072107..28ced83 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -48,13 +48,13 @@ struct Long { LL ll; }; -int somevar = 0; +int somevar; enum class Color { RED, GREEN, BLUE }; void TestCase1() { - SomeStruct somevar{}; - Long othervar{}; + SomeStruct somevar; + Long othervar; int intvar; SomeStruct* ptrvar; SomeStruct** ptrptrvar; @@ -84,7 +84,6 @@ void TestCase1() { std::cout << NAMEOF(~intvar) << std::endl; // intvar std::cout << NAMEOF(!intvar) << std::endl; // intvar - std::cout << NAMEOF(somevar.SomeMethod1) << std::endl; // SomeMethod1 std::cout << NAMEOF(&SomeStruct::SomeMethod2) << std::endl; // SomeMethod2 std::cout << NAMEOF(SomeMethod3) << std::endl; // SomeMethod3 diff --git a/include/nameof.hpp b/include/nameof.hpp index 6595208..4a5cbf5 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -54,7 +54,7 @@ inline constexpr const char* Nameof(const char* name, const std::size_t length, #define NAMEOF(name) ::nameof::Nameof(NAMEOF_RAW(name), sizeof(NAMEOF_RAW(name)) / sizeof(char) - 1, sizeof(void(*)(__typeof__(name)))) // Used to obtain the string full name of a variable, type, function and etc. -#define NAMEOF_FULL(name) ::nameof::Nameof(NAMEOF_RAW(name), sizeof(void(*)(__typeof__(name)))) +#define NAMEOF_FULL(name) ::nameof::Nameof(NAMEOF_RAW(name), 0, sizeof(void(*)(__typeof__(name)))) #else diff --git a/test/test.cpp b/test/test.cpp index e7dc816..cf49c00 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -53,12 +53,12 @@ struct Long { LL ll; }; -int somevar = 0; +int somevar; enum class Color { RED, GREEN, BLUE }; TEST_CASE("constexpr") { - SomeStruct somevar{}; + SomeStruct somevar; SECTION("NAMEOF") { constexpr auto n = NAMEOF(somevar); @@ -82,8 +82,8 @@ TEST_CASE("constexpr") { } TEST_CASE("NAMEOF") { - SomeStruct somevar{}; - Long othervar{}; + SomeStruct somevar; + Long othervar; int intvar; SomeStruct* ptrvar; SomeStruct** ptrptrvar; @@ -122,7 +122,6 @@ TEST_CASE("NAMEOF") { } SECTION("NAMEOF_FUNCTION") { - REQUIRE(std::strcmp(NAMEOF(somevar.SomeMethod1), "SomeMethod1") == 0); REQUIRE(std::strcmp(NAMEOF(&SomeStruct::SomeMethod2), "SomeMethod2") == 0); REQUIRE(std::strcmp(NAMEOF(SomeMethod3), "SomeMethod3") == 0); } @@ -134,8 +133,8 @@ TEST_CASE("NAMEOF") { } TEST_CASE("NAMEOF_FULL") { - SomeStruct somevar{}; - Long othervar{}; + SomeStruct somevar; + Long othervar; int intvar; SomeStruct* ptrvar; SomeStruct** ptrptrvar; @@ -175,7 +174,6 @@ TEST_CASE("NAMEOF_FULL") { } SECTION("NAMEOF_FUNCTION_FULL") { - REQUIRE(std::strcmp(NAMEOF_FULL(somevar.SomeMethod1), "somevar.SomeMethod1") == 0); REQUIRE(std::strcmp(NAMEOF_FULL(&SomeStruct::SomeMethod2), "&SomeStruct::SomeMethod2") == 0); REQUIRE(std::strcmp(NAMEOF_FULL(SomeMethod3), "SomeMethod3") == 0); }