Menu

#75 0.6.2 warning: implicit declaration of function 'strptime'

closed-accepted
nobody
None
5
2009-12-15
2009-12-15
Jari Aalto
No

Compiling fails under Debian with error:

ftp-ls.c: In function 'ftp_parse_vms_ls':
ftp-ls.c:850: warning: implicit declaration of function 'strptime'

1) you need to define -DXOPEN_SOURCE in src/Makefile.in
2) You need to add "#include <time.h>"

See attached patch for the #include

Discussion

  • Jari Aalto

    Jari Aalto - 2009-12-15
     
  • Rumpeltux

    Rumpeltux - 2009-12-15
    • status: open --> closed-accepted
     
  • Jari Aalto

    Jari Aalto - 2009-12-15

    Make that -D_XOPEN_SOURCE (notice extra underscore)

     
  • Jari Aalto

    Jari Aalto - 2009-12-15

    It appear that it is not so straightforward. Other errors surface if -D_XOPEN_SOURCE is used. And if it is not defined, then the resulted binary won't work because strptime() was not defined.

    Please investigate if the code could eb rewritten without strptime().

    [results with XOPEN defined]

    gcc -Wall -g -O2 -DLOCALEDIR=\"/usr/share/locale\" -D_XOPEN_SOURCE -DENABLE_NLS -DHAVE_STRING_H -c -o wput.o wput.c
    wput.c: In function 'readwputrc':
    wput.c:586: warning: cast to pointer from integer of different size
    wput.c: In function 'commandlineoptions':
    wput.c:680: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int'
    gcc -Wall -g -O2 -DLOCALEDIR=\"/usr/share/locale\" -D_XOPEN_SOURCE -DENABLE_NLS -DHAVE_STRING_H -c -o netrc.o netrc.c
    netrc.c: In function 'parse_netrc':
    netrc.c:192: warning: implicit declaration of function 'strdup'
    netrc.c:192: warning: incompatible implicit declaration of built-in function 'strdup'
    gcc -Wall -g -O2 -DLOCALEDIR=\"/usr/share/locale\" -D_XOPEN_SOURCE -DENABLE_NLS -DHAVE_STRING_H -c -o ftp.o ftp.c
    ftp.c: In function 'do_send':
    ftp.c:364: warning: implicit declaration of function 'usleep'
    ftp.c: In function 'open_input_file':
    ftp.c:210: warning: 'fd' may be used uninitialized in this function
    ftp.c: In function 'try_do_cwd':
    ftp.c:96: warning: 'res' may be used uninitialized in this function
    gcc -Wall -g -O2 -DLOCALEDIR=\"/usr/share/locale\" -D_XOPEN_SOURCE -DENABLE_NLS -DHAVE_STRING_H -c -o ftplib.o ftplib.c
    ftplib.c: In function 'ftp_get_filesize':
    ftplib.c:482: warning: implicit declaration of function 'strtoll'
    gcc -Wall -g -O2 -DLOCALEDIR=\"/usr/share/locale\" -D_XOPEN_SOURCE -DENABLE_NLS -DHAVE_STRING_H -c -o utils.o utils.c
    gcc -Wall -g -O2 -DLOCALEDIR=\"/usr/share/locale\" -D_XOPEN_SOURCE -DENABLE_NLS -DHAVE_STRING_H -c -o progress.o progress.c
    gcc -Wall -g -O2 -DLOCALEDIR=\"/usr/share/locale\" -D_XOPEN_SOURCE -DENABLE_NLS -DHAVE_STRING_H -c -o socketlib.o socketlib.c
    gcc -Wall -g -O2 -DLOCALEDIR=\"/usr/share/locale\" -D_XOPEN_SOURCE -DENABLE_NLS -DHAVE_STRING_H -c -o queue.o queue.c
    gcc -Wall -g -O2 -DLOCALEDIR=\"/usr/share/locale\" -D_XOPEN_SOURCE -DENABLE_NLS -DHAVE_STRING_H -c -o ftp-ls.o ftp-ls.c
    ftp-ls.c: In function 'ftp_parse_unix_ls':
    ftp-ls.c:314: warning: implicit declaration of function 'strdup'
    ftp-ls.c:314: warning: incompatible implicit declaration of built-in function 'strdup'
    ftp-ls.c: In function 'ftp_parse_winnt_ls':
    ftp-ls.c:466: warning: incompatible implicit declaration of built-in function 'strdup'
    ftp-ls.c: In function 'ftp_parse_vms_ls':
    ftp-ls.c:693: warning: incompatible implicit declaration of built-in function 'strdup'
    gcc -o ../wput wput.o netrc.o ftp.o ftplib.o utils.o progress.o socketlib.o queue.o ftp-ls.o -lgnutls-openssl

     
  • Jari Aalto

    Jari Aalto - 2009-12-15

    Solved.

    The Makefile must define -D_XOPEN_SOURCE=600 and with the patches, it compiles cleanly.

    ---------------------------
    Concerning "0.6.2 gcc --pedantic: C++ style comments are not allowed in"
    https://sourceforge.net/tracker/?func=detail&aid=2914793&group_id=141519&atid=749613

    Please fix the code. The C-standard does not allow C++ style comments. The code may compile with gcc, but not necessarily with other compilers.

     

Log in to post a comment.

MongoDB Logo MongoDB