Re: [Rd] longint

2018-08-16 Thread Hervé Pagès
On 08/16/2018 11:30 AM, Prof Brian Ripley wrote: On 16/08/2018 18:33, Hervé Pagès wrote: ... Only on Intel platforms int is 32 bits. Strictly speaking int is only required to be >= 16 bits. Who knows what the size of an int is on the Sunway TaihuLight for example ;-) R's configure checks tha

Re: [Rd] longint

2018-08-16 Thread Prof Brian Ripley
On 16/08/2018 18:33, Hervé Pagès wrote: On 08/16/2018 05:12 AM, Dirk Eddelbuettel wrote: On 15 August 2018 at 20:32, Benjamin Tyner wrote: | Thanks for the replies and for confirming my suspicion. | | Interestingly, src/include/S.h uses a trick: | |     #define longint int | | and so does the n

Re: [Rd] longint

2018-08-16 Thread Hervé Pagès
On 08/16/2018 05:12 AM, Dirk Eddelbuettel wrote: On 15 August 2018 at 20:32, Benjamin Tyner wrote: | Thanks for the replies and for confirming my suspicion. | | Interestingly, src/include/S.h uses a trick: | |    #define longint int | | and so does the nlme package (within src/init.c). As Bill

Re: [Rd] longint

2018-08-16 Thread Dirk Eddelbuettel
On 15 August 2018 at 20:32, Benjamin Tyner wrote: | Thanks for the replies and for confirming my suspicion. | | Interestingly, src/include/S.h uses a trick: | |    #define longint int | | and so does the nlme package (within src/init.c). As Bill Dunlap already told you, this is a) ancient an

Re: [Rd] longint

2018-08-15 Thread William Dunlap via R-devel
Note that include/S.h contains /* This is a legacy header and no longer documented. Code using it should be converted to use R.h */ ... /* is this a good idea? - conflicts with many versions of f2c.h */ # define longint int S.h was meant to be used while converting to R C code

Re: [Rd] longint

2018-08-15 Thread Benjamin Tyner
Thanks for the replies and for confirming my suspicion. Interestingly, src/include/S.h uses a trick:    #define longint int and so does the nlme package (within src/init.c). On 08/15/2018 02:47 PM, Hervé Pagès wrote: No segfault but a BIG warning from the compiler. That's because dereferencin

Re: [Rd] longint

2018-08-15 Thread Hervé Pagès
No segfault but a BIG warning from the compiler. That's because dereferencing the pointer inside your myfunc() function will produce an int that is not predictable i.e. it is system-dependent. Its value will depend on sizeof(long int) (which is not guaranteed to be 8) and on the endianness of the

Re: [Rd] longint

2018-08-15 Thread Brian Ripley
> On 15 Aug 2018, at 12:48, Duncan Murdoch wrote: > >> On 15/08/2018 7:08 AM, Benjamin Tyner wrote: >> Hi >> In my R package, imagine I have a C function defined: >> void myfunc(int *x) { >>// some code >> } >> but when I call it, I pass it a pointer to a longint instead of a >

Re: [Rd] longint

2018-08-15 Thread Duncan Murdoch
On 15/08/2018 7:08 AM, Benjamin Tyner wrote: Hi In my R package, imagine I have a C function defined:    void myfunc(int *x) {   // some code    } but when I call it, I pass it a pointer to a longint instead of a pointer to an int. Could this practice potentially result in a segfault

[Rd] longint

2018-08-15 Thread Benjamin Tyner
Hi In my R package, imagine I have a C function defined:    void myfunc(int *x) {   // some code    } but when I call it, I pass it a pointer to a longint instead of a pointer to an int. Could this practice potentially result in a segfault? Regards Ben __