I would just write this twice:

bool NameServers(vector<IPV4Address> *name_servers) {
#ifdef HAVE_DECL_RES_NINIT
  struct __res_state res;
  memset(&res, 0, sizeof(struct __res_state));
  if (res_ninit(&RES_VAR) != 0) {
    OLA_WARN << "Error getting nameservers";
    return false;
  }

   etc.
  res_nclose(&res);
#else 
   if (res_init() != 0) {
     OLA_WARN << "Error getting nameservers";
   ... etc.

#endif  

I think that it easier to read than scattering ifdefs through the code.