Skip to content
Prev 61534 / 63424 Next

Breaking Change in Rcomplex Layout?

On 4/3/23 15:50, Michael Milton wrote:
That seems like the generator does not support anonymous structures. 
Thanks for letting me know, but I am afraid it is not something that 
could be fixed on the R end.
No, you can access the fields as before in C (C11):

Rcomplex z;

z.r = 1; z.i = 2

this is what anonymous structures allow, this is why the structure is 
anonymous, not to break existing code.? The union there is to tell the 
compiler about the aliasing, to prevent it from misoptimizing the code. 
As far as I can tell this is valid C code, not a breaking change.

The only issues I know about so far are that you get a warning for 
initializations such as "z = {1, 2}", but still, they will be 
interpreted correctly by the compiler within the standard. However, "z = 
{ .r = 1, .i = 2}" worked before and works with the change.

The definition unfortunately is not valid C++, but works with C++ 
language extensions supported at least by GCC and clang, yet you may see 
warnings. R itself doesn't use C++, but some packages do.

Please note your subject is not quite right: the layout of Rcomplex did 
not change, at least not on systems supported by R. The layout is the 
same on systems which use self-alignment of structures.

Also please keep in mind R-devel is meant for unstable changes, it may 
not work, things may be reverted, it is partially used for testing. I've 
still tested this on all CRAN and Bioconductor packages before 
committing even to R-devel, but this is not always done and cannot be 
due to how much resources it takes. Obviously this will get a NEWS entry 
when/if it gets ported to 4.3.0 branch, in the form it would have at 
that point.

Best
Tomas