Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
Me pregunto cómo se compiló este código a pesar de que struct iwreq no tiene ifr_name como miembro

Escribí un código muy simple usando struct iwreq. Además, esperaba que esto fuera un error. Pero está compilado y funciona.

Miré dentro de linux/wireless.h que tiene la definición de struct iwreq. Y el iwreq no tiene ifr_name como miembro.

¿Alguien me puede dar una idea? Aquí está el código simple.

 #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 answers
Answer question

0

wireless.h incluye if.h , y dentro if.h puedes encontrar:

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

Así que el código se traduce a:

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

0

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

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

Y en /usr/include/linux/if.h hay:

 #define ifr_name ifr_ifrn.ifrn_name /* interface name */
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!