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 build error on Linux #1

Open
wants to merge 1 commit into
base: master
from

Conversation

1 participant
@mame
Copy link

mame commented Dec 21, 2018

gem install string-crypt fails on my Ubuntu 18.10.

$ rake test
cd tmp/x86_64-linux/string/crypt/2.5.3
/usr/bin/make
compiling ../../../../../ext/string/crypt/crypt.c
In file included from /home/mame/local/include/ruby-2.5.0/ruby.h:33,
                 from ../../../../../ext/string/crypt/crypt.c:3:
../../../../../ext/string/crypt/crypt.c: In function ‘rb_string_crypt’:
../../../../../ext/string/crypt/crypt.c:81:35: error: invalid application of ‘sizeof’ to incomplete type ‘struct crypt_data’
     data = ALLOCV(databuf, sizeof(struct crypt_data));
                                   ^~~~~~
/home/mame/local/include/ruby-2.5.0/ruby/ruby.h:1652:28: note: in definition of macro ‘RB_ALLOCV’
 # define RB_ALLOCV(v, n) ((n) < RUBY_ALLOCV_LIMIT ? \
                            ^
../../../../../ext/string/crypt/crypt.c:81:12: note: in expansion of macro ‘ALLOCV’
     data = ALLOCV(databuf, sizeof(struct crypt_data));
            ^~~~~~
In file included from /usr/include/stdlib.h:566,
                 from /home/mame/local/include/ruby-2.5.0/ruby/defines.h:120,
                 from /home/mame/local/include/ruby-2.5.0/ruby/ruby.h:29,
                 from /home/mame/local/include/ruby-2.5.0/ruby.h:33,
                 from ../../../../../ext/string/crypt/crypt.c:3:
../../../../../ext/string/crypt/crypt.c:81:35: error: invalid application of ‘sizeof’ to incomplete type ‘struct crypt_data’
     data = ALLOCV(databuf, sizeof(struct crypt_data));
                                   ^~~~~~
/home/mame/local/include/ruby-2.5.0/ruby/ruby.h:1662:22: note: in expansion of macro ‘RB_ALLOCV’
 #define ALLOCV(v, n) RB_ALLOCV(v, n)
                      ^~~~~~~~~
../../../../../ext/string/crypt/crypt.c:81:12: note: in expansion of macro ‘ALLOCV’
     data = ALLOCV(databuf, sizeof(struct crypt_data));
            ^~~~~~
In file included from /home/mame/local/include/ruby-2.5.0/ruby.h:33,
                 from ../../../../../ext/string/crypt/crypt.c:3:
../../../../../ext/string/crypt/crypt.c:81:35: error: invalid application of ‘sizeof’ to incomplete type ‘struct crypt_data’
     data = ALLOCV(databuf, sizeof(struct crypt_data));
                                   ^~~~~~
/home/mame/local/include/ruby-2.5.0/ruby/ruby.h:1654:37: note: in definition of macro ‘RB_ALLOCV’
          rb_alloc_tmp_buffer(&(v), (n)))
                                     ^
../../../../../ext/string/crypt/crypt.c:81:12: note: in expansion of macro ‘ALLOCV’
     data = ALLOCV(databuf, sizeof(struct crypt_data));
            ^~~~~~
../../../../../ext/string/crypt/crypt.c:83:9: error: dereferencing pointer to incomplete type ‘struct crypt_data’
     data->initialized = 0;
         ^~
../../../../../ext/string/crypt/crypt.c:85:11: warning: implicit declaration of function ‘crypt_r’; did you mean ‘crypt’? [-Wimplicit-function-declaration]
     res = crypt_r(s, saltp, data);
           ^~~~~~~
           crypt
../../../../../ext/string/crypt/crypt.c:85:9: warning: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
     res = crypt_r(s, saltp, data);
         ^
../../../../../ext/string/crypt/crypt.c: At top level:
cc1: warning: unrecognized command line option ‘-Wno-self-assign’
cc1: warning: unrecognized command line option ‘-Wno-constant-logical-operand’
cc1: warning: unrecognized command line option ‘-Wno-parentheses-equality’
make: *** [Makefile:242: crypt.o] エラー 1
rake aborted!
Command failed with status (2): [/usr/bin/make...]

Tasks: TOP => test => compile => compile:x86_64-linux => compile:string/crypt:x86_64-linux => copy:string/crypt:x86_64-linux:2.5.3 => tmp/x86_64-linux/string/crypt/2.5.3/string/crypt.so
(See full trace by running task with --trace)

#define _GNU_SOURCE is needed to use crypt_r.
I'm unsure why, but rearranging #include directives fixes the issue.

Fix build error on Linux
`#define _GNU_SOURCE` is needed to use `crypt_r`.
I'm unsure why, but rearranging `#include` directives fixes the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment