Foreign interface: warnings and errors "term arity has changed from int to size_t" after update

17 views
Skip to first unread message

Marijn Schraagen

unread,
Nov 17, 2015, 7:42:12 AM11/17/15
to SWI-Prolog
I've tried to install the latest development version of SWI-Prolog, in order to removing debugging flags used in a previous compilation. Now the foreign interface gives warnings and errors when compiling a C++ program.

Steps taken:
In (..)/swipl-devel/src/:
make distclean
git pull
./prepare
./configure
sudo make
sudo make install

In (..)/swipl-devel/packages/cpp:
make distclean
./configure
sudo make
(output: nothing to do for this package)
sudo make install
(output: /usr/bin/install -c -m 644 SWI-cpp.h /usr/local/lib/swipl-7.3.11/include)

Note: g git pull in swipl-devel/packages/cpp returns 'not in a branch' while git pull in /swipl-devel returns 'up to date'.

Now I have SWI-Prolog Version 7.3.11-43-gfa0eb26-DIRTY which works from the terminal. When compiling my C++ code I get the following warnings:
In file included from test.cc:8:0:
/usr/local/lib/swipl-7.3.11/include/SWI-Prolog.h:1158:2: warning: #warning "Term arity has changed from int to size_t." [-Wcpp]
 
#warning "Term arity has changed from int to size_t."
 
^
/usr/local/lib/swipl-7.3.11/include/SWI-Prolog.h:1159:2: warning: #warning "Please update your code and use #define PL_ARITY_AS_SIZE 1." [-Wcpp]
 
#warning "Please update your code and use #define PL_ARITY_AS_SIZE 1."
 
^

When I provide the directive #define PL_ARITY_AS_SIZE 1 there are errors:
/usr/local/lib/swipl-7.3.11/include/SWI-cpp.h: In member function int PlTerm::arity()’:
/usr/local/lib/swipl-7.3.11/include/SWI-Prolog.h:1150:60: error: cannot convert int*’ to size_t* {aka long unsigned int*}’ for argument 3 to int PL_get_name_arity_sz(term_t, atom_t*, size_t*)’
 
#define PL_get_name_arity(t,n,a) PL_get_name_arity_sz(t,n,a)
                                                           
^
/usr/local/lib/swipl-7.3.11/include/SWI-cpp.h:747:8: note: in expansion of macro PL_get_name_arity
   
if ( PL_get_name_arity(ref, &name, &arity) )
       
^
etc.

Should I use the version with the warnings, or is there some kind of fix?

Thanks in advance, Marijn

Jan Wielemaker

unread,
Nov 17, 2015, 7:46:37 AM11/17/15
to Marijn Schraagen, SWI-Prolog
Hi Marijn,

See https://groups.google.com/forum/#!topic/swi-prolog/hTHWeu9JsRQ

With the next release there will be additional documentation and a
ChangeLog announcement ...

Cheers --- Jan
> Infile included fromtest.cc:8:0:
> /usr/local/lib/swipl-7.3.11/include/SWI-Prolog.h:1158:2:warning:#warning"Term
> arity has changed from int to size_t."[-Wcpp]
> #warning"Term arity has changed from int to size_t."
> ^
> /usr/local/lib/swipl-7.3.11/include/SWI-Prolog.h:1159:2:warning:#warning"Please
> update your code and use #define PL_ARITY_AS_SIZE 1."[-Wcpp]
> #warning"Please update your code and use #define PL_ARITY_AS_SIZE 1."
> ^
> |
>
> When I provide the directive #define PL_ARITY_AS_SIZE 1 there are errors:
> |
> /usr/local/lib/swipl-7.3.11/include/SWI-cpp.h:Inmember
> function‘intPlTerm::arity()’:
> /usr/local/lib/swipl-7.3.11/include/SWI-Prolog.h:1150:60:error:cannot
> convert ‘int*’to ‘size_t*{aka longunsignedint*}’forargument ‘3’to
> ‘intPL_get_name_arity_sz(term_t,atom_t*,size_t*)’
> #definePL_get_name_arity(t,n,a)PL_get_name_arity_sz(t,n,a)
> ^
> /usr/local/lib/swipl-7.3.11/include/SWI-cpp.h:747:8:note:inexpansion of
> macro ‘PL_get_name_arity’
> if(PL_get_name_arity(ref,&name,&arity))
> ^
> |
> etc.
>
> Should I use the version with the warnings, or is there some kind of fix?
>
> Thanks in advance, Marijn
>
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swi-prolog+...@googlegroups.com
> <mailto:swi-prolog+...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/swi-prolog.
> For more options, visit https://groups.google.com/d/optout.

Boris Vassilev

unread,
Nov 17, 2015, 7:50:07 AM11/17/15
to SWI-Prolog
Hi Marijn and Jan,

in the original email (that you also linked) it said to use:

==
#define PL_ARITY_AS_SIZE
#include <SWI-Prolog.h>
==

while it seems that the warning lead Marijn to believe that it should be (guessing here):

==
#define PL_ARITY_AS_SIZE 1
#include <SWI-Prolog.h>
==

(the "1" should not be there?)


Currently in the EEST time zone: This is UTC +3:00 (and I sleep at night)
Save our in-boxes! http://emailcharter.org

To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.

Jan Wielemaker

unread,
Nov 17, 2015, 7:56:40 AM11/17/15
to Boris Vassilev, SWI-Prolog
On 11/17/2015 01:49 PM, Boris Vassilev wrote:
> Hi Marijn and Jan,
>
> in the original email (that you also linked) it said to use:
>
> ==
> #define PL_ARITY_AS_SIZE
> #include <SWI-Prolog.h>
> ==
>
> while it seems that the warning lead Marijn to believe that it should be
> (guessing here):
>
> ==
> #define PL_ARITY_AS_SIZE 1
> #include <SWI-Prolog.h>
> ==
>
> (the "1" should not be there?)

Either is fine. The header uses `#ifdef PL_ARITY_AS_SIZE`. With this
def, you get the new size_t versions of the functions. That typically
means you need to change variables that represent arity from `int` to
`size_t`

Cheers --- Jan

Carlo Capelli

unread,
Nov 22, 2015, 4:26:28 AM11/22/15
to Jan Wielemaker, Marijn Schraagen, SWI-Prolog
I wonder if ~/lib/pkgconfig/swipl.pc (kindly provided after we build from sources) will be updated,
then sparing us to hardcode the define around (maybe I'm missing some detail).

Thanks, Carlo


To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages