I am using macros to determine a variable's real type based on a pattern, and I am getting some weird macro errors that I do not understand:
a.cpp:15:4: error: '#' is not followed by a macro parameter
#define USING_INTEGER\
^
a.cpp:15:11: error: unknown type name 'USING_INTEGER'
#define USING_INTEGER\
^
a.cpp:16:2: error: expected unqualified-id
else if (matchRegex(DOUBLE_REGEX, val))\
^
3 errors generated.
Why is this happening? I have no idea, please provide some help if you know why.
#include "example_3.cpp"
#include <regex>
std::string INT_REGEX = "^[-+]?\\d+$",
DOUBLE_REGEX = "^[-+]?\\d+\\.\\d?$",
BOOLEAN_REGEX = "^(true|false)$";
bool matchRegex(std::string pattern, std::string inputString) {
std::regex expression(pattern);
return std::regex_match(inputString, expression);
}
#define determineType(var)\
if (matchRegex(INT_REGEX, val))\
#define USING_INTEGER\
else if (matchRegex(DOUBLE_REGEX, val))\
#define USING_DOUBLE\
else if (matchRegex(BOOLEAN_REGEX, val))\
#define USING_BOOL\
else\
#define USING_RAW