pioz / chess

A fast chess library that use bitboards to play chess with Ruby
GNU Lesser General Public License v3.0
59 stars 17 forks source link

Add CFLAGS for c99 #16

Closed galiminus closed 6 years ago

galiminus commented 6 years ago

Hi there!

I had a compilation error when I tried to deploy an application (which use 'chess') on Dokku. I'm really not sure if it's more an issue from 'chess' or from Dokku but the fix sounds simpler here x)

Have a great day!

pioz commented 6 years ago

Can you post the compile error, so I can try to find the problem? Thank you very much for your support!

galiminus commented 6 years ago

Sure! Here it is:

       Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
       current directory: /tmp/build/vendor/bundle/ruby/2.3.0/gems/chess-0.2.0/ext
       /tmp/build/vendor/ruby-2.3.4/bin/ruby -r ./siteconf20171015-259-rf6896.rb
       extconf.rb
       creating Makefile
       current directory: /tmp/build/vendor/bundle/ruby/2.3.0/gems/chess-0.2.0/ext
       make "DESTDIR=" clean
       current directory: /tmp/build/vendor/bundle/ruby/2.3.0/gems/chess-0.2.0/ext
       make "DESTDIR="
       compiling bitboard.c
       bitboard.c: In function ‘squares’:
       bitboard.c:102:3: error: ‘for’ loop initial declarations are only allowed in C99
       mode
       for (int i = 0; i < 64; i++)
       ^
       bitboard.c:102:3: note: use option -std=c99 or -std=gnu99 to compile your code
       bitboard.c: In function ‘print_bitboard’:
       bitboard.c:143:3: error: ‘for’ loop initial declarations are only allowed in C99
       mode
       for (int i = 7; i >= 0; i--) // rank => top to bottom
       ^
       bitboard.c:145:7: error: ‘for’ loop initial declarations are only allowed in C99
       mode
       for (int j = 0; j < 8; j++) // file => left to right
       ^
       bitboard.c: In function ‘precalculate_xray_attack_white_pawn’:
       bitboard.c:252:3: error: ‘for’ loop initial declarations are only allowed in C99
       mode
       for (int i = 0; i < 64; i++)
       ^
       bitboard.c: In function ‘precalculate_xray_attack_black_pawn’:
       bitboard.c:262:3: error: ‘for’ loop initial declarations are only allowed in C99
       mode
       for (int i = 0; i < 64; i++)
       ^
       bitboard.c: In function ‘precalculate_xray_knight’:
       bitboard.c:272:3: error: ‘for’ loop initial declarations are only allowed in C99
       mode
       for (int i = 0; i < 64; i++)
       ^
       bitboard.c: In function ‘precalculate_xray_king’:
       bitboard.c:289:3: error: ‘for’ loop initial declarations are only allowed in C99
       mode
       for (int i = 0; i < 64; i++)
       ^
       bitboard.c:292:7: error: ‘for’ loop initial declarations are only allowed in C99
       mode
       for (int j = 0; j < 8; j++)
       ^
       bitboard.c: In function ‘xray_rook’:
       bitboard.c:351:3: error: ‘for’ loop initial declarations are only allowed in C99
       mode
       for (int i = 0, dir = 0; i < 4; i++, dir+=2)
       ^
       bitboard.c: In function ‘xray_bishop’:
       bitboard.c:372:3: error: ‘for’ loop initial declarations are only allowed in C99
       mode
       for (int i = 0, dir = 1; i < 4; i++, dir+=2)
       ^
       make: *** [bitboard.o] Error 1
       make failed, exit code 2
       Gem files will remain installed in
       /tmp/build/vendor/bundle/ruby/2.3.0/gems/chess-0.2.0 for inspection.
       Results logged to
       /tmp/build/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/chess-0.2.0/gem_make.out
       An error occurred while installing chess (0.2.0), and Bundler cannot continue.
       Make sure that `gem install chess -v '0.2.0'` succeeds before bundling.