#define LOG(format,...) Logger::Log(format,__VA_ARGS__) #define STRIP(netIp) GeneralUtils::inet_ntop_(netIp) string GeneralUtils::inet_ntop_(unsigned int netIp){ char strIP[INET_ADDRSTRLEN]; in_addr sin_addr; sin_addr.s_addr = netIp; inet_ntop(AF_INET, &sin_addr.s_addr, strIP, sizeof strIP); return string(strIP); }
when calling:
LOG("src %s dst %s" ,STRIP(src_ip_));
I get a compilation error:
cannot pass objects of non-trivially-copyable type 'std::string {aka struct std::basic_string<char>}' through '...'
I understand that varargs is compatible with c, so I cannot send it a string. Is there an easy way around it? Is this correct to fix:
#define STRIP(netIp) GeneralUtils::inet_ntop_(netIp).data()
source share