Posts

C++ Macro - pass string and use as a variable name

Image
-1 So i'm working on a small hobby project which i have implemented a very basic reflection of enums. I have come across an issue which i'm struggling to find a solution. This would be an ideal call which i'm looking for Reflect_Value("TestStringName", "StringValue") the first parameter is a string which is intended to be appended onto a variable name and the second to be the actual string value #define Reflect_Value(name,t) namespace Reflection static ReflectedObject object_##name = ReflectedObject(name,t); now the macro would then take that first parameter and be used as object_TestStringName but when i pass the string in the code evaluates to object_"TestStringName" which doesn't compile. What am i doing wrong here or can anyone provide any solutions to how i could get this functionality please. its important to have the name be something i guess recognisable and also unique so i can reflect many objects Thanks c++ mac...

University of Hawaii at Manoa

Image
University of Hawaiʻi at Mānoa Motto "Ma luna a'e o na lahui a pau ke ola o ke kanaka" (Hawaiian) Motto in English "Above all nations is humanity" Type Public flagship Land-grant Sea-grant Space-grant Established 1907 Endowment $271.2 million (2016) [1] Chancellor David Lassner [2] President David Lassner Students 17,710 (fall 2018) [3] Undergraduates 12,968 [3] Postgraduates 4,742 [3] Location Honolulu , Hawaii , U.S. 21°17′49″N 157°49′01″W  /  21.297°N 157.817°W  / 21.297; -157.817 Coordinates: 21°17′49″N 157°49′01″W  /  21.297°N 157.817°W  / 21.297; -157.817 Campus Urban, 320 acres (1.3 km 2 ) Colors Green, White [4] [5]             Athletics NCAA - National Collegiate Athletic Association, Division I Big West (most sports); MW, MPSF Nickname "Rainbow Warriors" (men) "Rainbow Wahine"...