Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rping.c on FreeBSD #20

Closed
wants to merge 1 commit into from
Closed

Fix rping.c on FreeBSD #20

wants to merge 1 commit into from

Conversation

yzgyyang
Copy link

The include directive of netinet/in.h must be present before resolv.h on FreeBSD, otherwise, the following errors will occur:

rping.c:82:27: error: use of undeclared identifier 'IPPROTO_TCP'
  if (type == 0) { type = IPPROTO_TCP; } else { type = IPPROTO_UDP; }
                          ^
rping.c:82:56: error: use of undeclared identifier 'IPPROTO_UDP'
  if (type == 0) { type = IPPROTO_TCP; } else { type = IPPROTO_UDP; }
                                                       ^
rping.c:117:24: error: variable has incomplete type 'struct sockaddr_in'
    struct sockaddr_in c_address;
                       ^
rping.c:117:12: note: forward declaration of 'struct sockaddr_in'
    struct sockaddr_in c_address;
           ^
rping.c:128:17: error: use of undeclared identifier 'IPPROTO_UDP'
                      type == IPPROTO_UDP ? SOCK_DGRAM : SOCK_STREAM,
                              ^
4 errors generated.

The reason is that the resolv.h on FreeBSD is not yet self-contained, see this bug report: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=182466

This fix was committed with the FreeBSD port net/R-cran-pingr in https://cgit.freebsd.org/ports/commit/?id=fce80f530301d0079d84bc4b818ba957ad29617b.

The include directive of `netinet/in.h` must be present before `resolv.h` on FreeBSD, otherwise, the following errors will occur:

```
rping.c:82:27: error: use of undeclared identifier 'IPPROTO_TCP'
  if (type == 0) { type = IPPROTO_TCP; } else { type = IPPROTO_UDP; }
                          ^
rping.c:82:56: error: use of undeclared identifier 'IPPROTO_UDP'
  if (type == 0) { type = IPPROTO_TCP; } else { type = IPPROTO_UDP; }
                                                       ^
rping.c:117:24: error: variable has incomplete type 'struct sockaddr_in'
    struct sockaddr_in c_address;
                       ^
rping.c:117:12: note: forward declaration of 'struct sockaddr_in'
    struct sockaddr_in c_address;
           ^
rping.c:128:17: error: use of undeclared identifier 'IPPROTO_UDP'
                      type == IPPROTO_UDP ? SOCK_DGRAM : SOCK_STREAM,
                              ^
4 errors generated.
```

The reason is that the `resolv.h` on FreeBSD is not yet self-contained, see this bug report: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=182466

This fix was committed with the FreeBSD port `net/R-cran-pingr` in https://cgit.freebsd.org/ports/commit/?id=fce80f530301d0079d84bc4b818ba957ad29617b.
@gaborcsardi
Copy link
Member

Thanks! I think you can merge this into #19. Could you also please also add an item to NEWS.md? Thanks again!

@yzgyyang
Copy link
Author

Thanks! I think you can merge this into #19. Could you also please also add an item to NEWS.md? Thanks again!

Will do - thank you!

@yzgyyang yzgyyang closed this Jan 14, 2022
@yzgyyang yzgyyang deleted the patch-2 branch January 14, 2022 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants