Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
I am questioning how this code compiled even though struct iwreq does not have ifr_name as a member

I wrote very simple code using struct iwreq. Also, I expected this will be error. But it is compiled and works.

I looked inside linux/wireless.h which has the definition of struct iwreq. And the iwreq does not ifr_name as a member.

Would someone can give me an idea? Here is the simple code.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <linux/wireless.h>

int main(void)
{
   char *intf = "eth0";
   struct iwreq iwr;

   strncpy(iwr.ifr_name, intf, sizeof(iwr.ifr_name));

   printf("main : intf = %s, iwr.ifr_name = %s\n", intf, iwr.ifr_name);
   return 0;
}
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

wireless.h includes if.h, and inside if.h you can find:

#define ifr_name    ifr_ifrn.ifrn_name  /* interface name   */

So the code is translated to:

strncpy(iwr.ifr_ifrn.ifrn_name, intf, sizeof(iwr.ifr_ifrn.ifrn_name));
over 4 years ago · Santiago Trujillo Denunciar

0

/usr/include/linux/wireless.h includes linux/if.h:

#include <linux/if.h>           /* for IFNAMSIZ and co... */

And in /usr/include/linux/if.h there is:

#define ifr_name    ifr_ifrn.ifrn_name  /* interface name   */
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda