Re: [R-pkg-devel] Error handling in C code

2024-05-06 Thread Jarrod Hadfield
Hi,

Using Rf_error() rather than error() fixed the problem. Not sure why the 
problem was only flagged on Debian, but it seems to have been triggered by 
R_NO_REMAP being defined (which will be default in R 4.5.0).

Thanks for the help.

Jarrod

From: Simon Urbanek 
Date: Monday, 6 May 2024 at 03:38
To: Jarrod Hadfield 
Cc: r-package-devel@r-project.org 
Subject: Re: [R-pkg-devel] Error handling in C code
This email was sent to you by someone outside the University.
You should only click on links or attachments if you are certain that the email 
is genuine and the content is safe.

Jarrod,

could you point us to the code? There is not much to go by based on your email. 
One thing just in general: it's always safer to not re-map function names, 
especially since "error" can be defined in many random other headers, so it's 
better to use Rf_error() instead to avoid confusions with 3rd party headers 
that may (re-)define the "error" macro (depending on the order you include them 
in).

Cheers,
Simon


> On 4/05/2024, at 3:17 AM, Jarrod Hadfield  wrote:
>
> Hi,
>
> I have an R library with C code in it. It has failed the CRAN checks for 
> Debian.  The problem is with the error function being undefined. Section 6.2 
> of the Writing R extensions (see below) suggests error handling can be 
> handled by error and the appropriate header file is included in R.h, but this 
> seems not to be the case?
>
> Any help would be appreciated!
>
> Thanks,
>
> Jarrod
>
> 6.2 Error signaling
>
> The basic error signaling routines are the equivalents of stop and warning in 
> R code, and use the same interface.
>
> void error(const char * format, ...);
> void warning(const char * format, ...);
> void errorcall(SEXP call, const char * format, ...);
> void warningcall(SEXP call, const char * format, ...);
> void warningcall_immediate(SEXP call, const char * format, ...);
>
> These have the same call sequences as calls to printf, but in the simplest 
> case can be called with a single character string argument giving the error 
> message. (Don�t do this if the string contains �%� or might otherwise be 
> interpreted as a format.)
>
> These are defined in header R_ext/Error.h included by R.h.
> The University of Edinburgh is a charitable body, registered in Scotland, 
> with registration number SC005336. Is e buidheann carthannais a th� ann an 
> Oilthigh Dh�n �ideann, cl�raichte an Alba, �ireamh cl�raidh SC005336.
>
>   [[alternative HTML version deleted]]
>
> __
> R-package-devel@r-project.org mailing list
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-package-devel=05%7C02%7C%7C27d13d00316a466dc91f08dc6d759134%7C2e9f06b016694589878910a06934dc61%7C0%7C0%7C638505599232790068%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C=bhr0SQN0UJq4FQgEgboltgm6dH1wo5aonYTDqRvsf2g%3D=0<https://stat.ethz.ch/mailman/listinfo/r-package-devel>

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Error handling in C code

2024-05-05 Thread Simon Urbanek
Jarrod,

could you point us to the code? There is not much to go by based on your email. 
One thing just in general: it's always safer to not re-map function names, 
especially since "error" can be defined in many random other headers, so it's 
better to use Rf_error() instead to avoid confusions with 3rd party headers 
that may (re-)define the "error" macro (depending on the order you include them 
in).

Cheers,
Simon


> On 4/05/2024, at 3:17 AM, Jarrod Hadfield  wrote:
> 
> Hi,
> 
> I have an R library with C code in it. It has failed the CRAN checks for 
> Debian.  The problem is with the error function being undefined. Section 6.2 
> of the Writing R extensions (see below) suggests error handling can be 
> handled by error and the appropriate header file is included in R.h, but this 
> seems not to be the case?
> 
> Any help would be appreciated!
> 
> Thanks,
> 
> Jarrod
> 
> 6.2 Error signaling
> 
> The basic error signaling routines are the equivalents of stop and warning in 
> R code, and use the same interface.
> 
> void error(const char * format, ...);
> void warning(const char * format, ...);
> void errorcall(SEXP call, const char * format, ...);
> void warningcall(SEXP call, const char * format, ...);
> void warningcall_immediate(SEXP call, const char * format, ...);
> 
> These have the same call sequences as calls to printf, but in the simplest 
> case can be called with a single character string argument giving the error 
> message. (Don�t do this if the string contains �%� or might otherwise be 
> interpreted as a format.)
> 
> These are defined in header R_ext/Error.h included by R.h.
> The University of Edinburgh is a charitable body, registered in Scotland, 
> with registration number SC005336. Is e buidheann carthannais a th� ann an 
> Oilthigh Dh�n �ideann, cl�raichte an Alba, �ireamh cl�raidh SC005336.
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Error handling in C code

2024-05-03 Thread Duncan Murdoch
Most functions in R have a prefix on their name, with aliases defined so 
you can use the function without the prefix.  But you can turn off the 
aliasing, in which case you need the true name.  I think for all of the 
functions you list the prefix is "Rf_", so they are "Rf_error", etc.


Perhaps you turned off the aliasing?

Duncan Murdoch

On 03/05/2024 11:17 a.m., Jarrod Hadfield wrote:

Hi,

I have an R library with C code in it. It has failed the CRAN checks for 
Debian.  The problem is with the error function being undefined. Section 6.2 of 
the Writing R extensions (see below) suggests error handling can be handled by 
error and the appropriate header file is included in R.h, but this seems not to 
be the case?

Any help would be appreciated!

Thanks,

Jarrod

6.2 Error signaling

The basic error signaling routines are the equivalents of stop and warning in R 
code, and use the same interface.

void error(const char * format, ...);
void warning(const char * format, ...);
void errorcall(SEXP call, const char * format, ...);
void warningcall(SEXP call, const char * format, ...);
void warningcall_immediate(SEXP call, const char * format, ...);

These have the same call sequences as calls to printf, but in the simplest case 
can be called with a single character string argument giving the error message. 
(Don�t do this if the string contains �%� or might otherwise be interpreted as 
a format.)

These are defined in header R_ext/Error.h included by R.h.
The University of Edinburgh is a charitable body, registered in Scotland, with 
registration number SC005336. Is e buidheann carthannais a th� ann an Oilthigh 
Dh�n �ideann, cl�raichte an Alba, �ireamh cl�raidh SC005336.

[[alternative HTML version deleted]]


__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] Error handling in C code

2024-05-03 Thread Jarrod Hadfield
Hi,

I have an R library with C code in it. It has failed the CRAN checks for 
Debian.  The problem is with the error function being undefined. Section 6.2 of 
the Writing R extensions (see below) suggests error handling can be handled by 
error and the appropriate header file is included in R.h, but this seems not to 
be the case?

Any help would be appreciated!

Thanks,

Jarrod

6.2 Error signaling

The basic error signaling routines are the equivalents of stop and warning in R 
code, and use the same interface.

void error(const char * format, ...);
void warning(const char * format, ...);
void errorcall(SEXP call, const char * format, ...);
void warningcall(SEXP call, const char * format, ...);
void warningcall_immediate(SEXP call, const char * format, ...);

These have the same call sequences as calls to printf, but in the simplest case 
can be called with a single character string argument giving the error message. 
(Don�t do this if the string contains �%� or might otherwise be interpreted as 
a format.)

These are defined in header R_ext/Error.h included by R.h.
The University of Edinburgh is a charitable body, registered in Scotland, with 
registration number SC005336. Is e buidheann carthannais a th� ann an Oilthigh 
Dh�n �ideann, cl�raichte an Alba, �ireamh cl�raidh SC005336.

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel