Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

#2694 closed defect (worksforme)

linking issue for htonl, etc when using -std=c99

Reported by: Joel Sherrill Owned by: Sebastian Huber
Priority: low Milestone: 5.1
Component: network/legacy Version: 5
Severity: normal Keywords:
Cc: Chris Johns, Gedare Bloom Blocked By:
Blocking:

Description

When -std=c99 is on the compile line, there is a linking error for undefined references to htonl, htons, ntohl, and ntohs. This test case is just for htonl but others should be similar.

This likely impacts the 4.11 branch of rtems-libbsd as well but I was testing on master.

Test case
======================
#include <arpa/inet.h>

int main(

int argc,
char argv

)
{

uint32_t v = (uint32_t) argc;
uint32_t rc = htonl(v);
return v;

}
======================

This script was what I used to find what caused the linking error to go away.

======================
RTEMS_MAKEFILE_PATH=/home/joel/rtems-4.11-work/tools/4.12/i386-rtems4.12/pc586/

i386-rtems4.12-gcc -std=c99 \

-B${RTEMS_MAKEFILE_PATH}/lib -specs bsp_specs -qrtems \
-D_XOPEN_SOURCE=600 -DUSE_SVID main.c -lbsd -lm -lbsd

i386-rtems4.12-gcc -std=c99 \

-B${RTEMS_MAKEFILE_PATH}/lib -specs bsp_specs -qrtems \
-DUSE_SVID main.c -lbsd -lm -lbsd

i386-rtems4.12-gcc -std=c99 \

-B${RTEMS_MAKEFILE_PATH}/lib -specs bsp_specs -qrtems \
main.c -lbsd -lm -lbsd

i386-rtems4.12-gcc \

-B${RTEMS_MAKEFILE_PATH}/lib -specs bsp_specs -qrtems \
main.c -lbsd -lm -lbsd

======================

Change History (5)

comment:1 Changed on 12/23/16 at 14:10:53 by Sebastian Huber

Priority: normallow

comment:2 Changed on 01/23/17 at 07:34:47 by Sebastian Huber

I cannot reproduce this problem on the master.

comment:3 Changed on 01/23/17 at 15:42:57 by Joel Sherrill

Resolution: worksforme
Status: newclosed

comment:4 Changed on 05/11/17 at 07:31:02 by Sebastian Huber

Milestone: 4.124.12.0

comment:5 Changed on 11/09/17 at 06:27:14 by Sebastian Huber

Milestone: 4.12.05.1

Milestone renamed

Note: See TracTickets for help on using tickets.