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

[BUG] Implicit definiton of accept4 function when building simulator on Arch Linux #2632

Open
1 task done
linguini1 opened this issue Sep 29, 2024 · 4 comments
Open
1 task done

Comments

@linguini1
Copy link
Contributor

Description / Steps to reproduce the issue

I was attempting to build the Simulator with the tcpblaster configuration to test out some NuttX networking, but I ran
into an implicit function definition error:

[linguini@pastabox nuttx]$ make -j
CC:  tcpblaster_server.c
LN: platform/board to /home/linguini/cuinspace/pico-nuttx/apps/platform/dummy
tcpblaster_server.c: In function ‘tcpblaster_server’:
tcpblaster_server.c:159:14: error: implicit declaration of function ‘accept4’; did you mean ‘accept’? [-Wimplicit-function-declaration]
  159 |   acceptsd = accept4(listensd, (FAR struct sockaddr *)&myaddr, &addrlen,
      |              ^~~~~~~
      |              accept
make[3]: *** [Makefile:92: tcpblaster_server.hobj] Error 1
make[2]: *** [Makefile:53: /home/linguini/cuinspace/pico-nuttx/apps/examples/tcpblaster_context] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:180: context] Error 2
make: *** [tools/Unix.mk:457: /home/linguini/cuinspace/pico-nuttx/apps/.context] Error 2
make: *** Waiting for unfinished jobs....

Looking at the manpages for accept4, it seems to require that _GNU_SOURCE be defined before the header is included.
I added -D_GNU_SOURCE to this line of the TCP blaster example, and it fixed the build issue on my machine. Others that
I am working with were able to build the example without any issues on Ubuntu, so I wanted to check and see if I am
perhaps taking the wrong approach before I open a PR to permanently add that change to the example.

I followed the first three steps listed in the simulator docs here.

make distclean
./tools/configure.sh sim:tcpblaster
make

On which OS does this issue occur?

[Linux]

What is the version of your OS?

Linux 6.10.10-arch1-1 x86_64 GNU/Linux

NuttX Version

master

Issue Architecture

[simulator]

Issue Area

[Applications], [Build System], [Configuring], [Networking]

Verification

  • I have verified before submitting the report.
@cederom
Copy link

cederom commented Sep 29, 2024

Thanks @linguini1 yes this problem was introduced recently by #2595 we are looking for a solution should show up soon :-)

@linguini1
Copy link
Contributor Author

Thanks @linguini1 yes this problem was introduced recently by #2595 we are looking for a solution should show up soon :-)

Ah, I missed seeing that! Would it be preferable for me to open a PR to add this new define, or shall I leave the solution to the original author?

@cederom
Copy link

cederom commented Sep 29, 2024

Lets wait for the original change author to reply.. accept4 is a non-standard extension that increases security.. we already noticed problems on macOS that does not have that call implemented.. no clue how _GNU_SOURCE will impact other compilers / compatibility avalanche.. but your hint may be right the solution!! :-)

@xiaoxiang781216
Copy link
Contributor

we can call accept4 on nuttx, but call accept on host.

gneworld pushed a commit to gneworld/nuttx-apps that referenced this issue Oct 3, 2024
[linguini@pastabox nuttx]$ make -j
CC:  tcpblaster_server.c
LN: platform/board to
/home/linguini/cuinspace/pico-nuttx/apps/platform/dummy
tcpblaster_server.c: In function ‘tcpblaster_server’:
tcpblaster_server.c:159:14: error: implicit declaration of function
‘accept4’; did you mean ‘accept’? [-Wimplicit-function-declaration]
  159 |   acceptsd = accept4(listensd, (FAR struct sockaddr *)&myaddr,
&addrlen,
      |              ^~~~~~~
      |              accept
make[3]: *** [Makefile:92: tcpblaster_server.hobj] Error 1
make[2]: *** [Makefile:53:
/home/linguini/cuinspace/pico-nuttx/apps/examples/tcpblaster_context]
Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:180: context] Error 2
make: *** [tools/Unix.mk:457:
/home/linguini/cuinspace/pico-nuttx/apps/.context] Error 2
make: *** Waiting for unfinished jobs....

from apache#2632

Signed-off-by: wanggang26 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants