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

error: implicit declaration of function 'mkdtemp' is invalid in C99 #1308

Closed
l2dy opened this issue Feb 18, 2019 · 5 comments

Comments

Projects
None yet
3 participants
@l2dy
Copy link

commented Feb 18, 2019

Bug summary

Fails to build from source on macOS (MacPorts or manual).

Current behavior

[  6%] Building C object src/core/CMakeFiles/weechat_core.dir/weechat.o
cd /opt/local/var/macports/build/_opt_source_macports_macports-ports_irc_weechat/weechat/work/build/src/core && /usr/bin/clang -DENABLE_NLS -DHAVE_CONFIG_H -DHAVE_GCRYPT -DHAVE_GNUTLS -DHAVE_ICONV -DHAVE_ZLIB -DWEECHAT_LICENSE=\"GPL3\" -DWEECHAT_VERSION=\"2.4\" -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_LARGE_FILES -I/opt/local/include -I/opt/local/var/macports/build/_opt_source_macports_macports-ports_irc_weechat/weechat/work/build  -pipe -Os -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -fsigned-char -Wall -Wextra -Werror-implicit-function-declaration -DNDEBUG -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -mmacosx-version-min=10.14   -o CMakeFiles/weechat_core.dir/weechat.o   -c /opt/local/var/macports/build/_opt_source_macports_macports-ports_irc_weechat/weechat/work/weechat-2.4/src/core/weechat.c
/opt/local/var/macports/build/_opt_source_macports_macports-ports_irc_weechat/weechat/work/weechat-2.4/src/core/weechat.c:441:28: error: implicit declaration of function 'mkdtemp' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        ptr_weechat_home = mkdtemp (temp_home_template);
                           ^
/opt/local/var/macports/build/_opt_source_macports_macports-ports_irc_weechat/weechat/work/weechat-2.4/src/core/weechat.c:441:26: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
        ptr_weechat_home = mkdtemp (temp_home_template);
                         ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 1 error generated.
make[2]: *** [src/core/CMakeFiles/weechat_core.dir/weechat.o] Error 1

Steps to reproduce

1. Update MacPorts Portfile to use official 2.4 tarball weechat-2.4.tar.bz2.
2. Build it.

Desired behavior

Compiles successfully.

Suggested solutions

Additional information


  • WeeChat version: 2.4
  • OS, distribution and version: macOS 10.14.3

@flashcode flashcode self-assigned this Feb 18, 2019

@flashcode flashcode added the bug label Feb 18, 2019

@flashcode

This comment has been minimized.

Copy link
Member

commented Feb 18, 2019

Function mkdtemp comes from stdlib.h (according to man mkdtemp), is POSIX.1-2008 and is in BSD.
It is not available at all on MacOS?

@l2dy

This comment has been minimized.

Copy link
Author

commented Feb 18, 2019

It comes from unistd.h in Xcode 10.1.

$ man -w mkdtemp
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/share/man/man3/mkdtemp.3
$ man mkdtemp | col -b

MKTEMP(3)		 BSD Library Functions Manual		     MKTEMP(3)

NAME
     mktemp, mkstemp, mkdtemp, mkdtempat_np, mkstemps, mkstempsat_np,
     mkostemp, mkostemps, mkostempsat_np -- make temporary file name (unique)

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     #include <unistd.h>

     char *
     mktemp(char *template);

     int
     mkstemp(char *template);

     char *
     mkdtemp(char *template);
[...]
@flashcode

This comment has been minimized.

Copy link
Member

commented Feb 18, 2019

If you add manually a line with #include <unistd.h> at the top of src/core/weechat.c, is that OK (compilation and run)?

@l2dy

This comment has been minimized.

Copy link
Author

commented Feb 18, 2019

If you add manually a line with #include <unistd.h> at the top of src/core/weechat.c, is that OK (compilation and run)?

OK with MacPorts.

@flashcode flashcode closed this in 6a9937f Feb 18, 2019

@flashcode flashcode removed the waiting info label Feb 18, 2019

@flashcode flashcode added this to the 2.5 milestone Feb 18, 2019

@7c6f434c 7c6f434c referenced this issue Feb 20, 2019

Merged

weechat: 2.3 -> 2.4 #56028

6 of 10 tasks complete

Ma27 added a commit to Ma27/nixpkgs that referenced this issue Feb 20, 2019

weechat: 2.3 -> 2.4
https://weechat.org/files/releasenotes/ReleaseNotes-devel.html#v2.4

Also applied a patch from the 2.5 branch in order to fix the darwin
build: weechat/weechat#1308

Ma27 added a commit to Ma27/nixpkgs that referenced this issue Feb 20, 2019

weechat: 2.3 -> 2.4
https://weechat.org/files/releasenotes/ReleaseNotes-devel.html#v2.4

Also applied a patch from the 2.5 branch in order to fix the darwin
build: weechat/weechat#1308
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.