Skip to content

gcc on windows warns for unnamed structs under cc() but not R CMD INSTALL #6471

@tdhock

Description

@tdhock

related to #6466 and #6468 which I observe also.

on windows using gcc/rtools44 I see no warning when compiling reorder.c (for example, other are affected too)

$ R CMD INSTALL .
* installing to library 'C:/Users/hoct2726/AppData/Local/R/win-library/4.4'
* installing *source* package 'data.table' ...
** using staged installation

   **********************************************
   WARNING: this package has a configure script
         It probably needs manual configuration
   **********************************************


** libs
using C compiler: 'gcc.exe (GCC) 13.2.0'
...
gcc  -I"C:/PROGRA~1/R/R-44~1.1/include" -DNDEBUG     -I"C:/rtools44/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c reorder.c -o reorder.o
gcc  -I"C:/PROGRA~1/R/R-44~1.1/include" -DNDEBUG     -I"C:/rtools44/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c shift.c -o shift.o

with cc(), I see a warning:

> cc()
C:/Users/hoct2726/R/data.table/src 
Running command:
MAKEFLAGS='-j CC=gcc CFLAGS=-fopenmp\ -std=c99\ -O3\ -pipe\ -Wall\ -pedantic\ -Wstrict-prototypes\ -isystem\ /usr/share/R/include\ -DWIN32\ -fno-common' R CMD SHLIB -o data_table.so *.c
using C compiler: 'gcc.exe (GCC) 13.2.0'
gcc -I"C:/PROGRA~1/R/R-44~1.1/include" -DNDEBUG     -I"C:/rtools44/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -fopenmp -std=c99 -O3 -pipe -Wall -pedantic -Wstrict-prototypes -isystem /usr/share/R/include -DWIN32 -fno-common -c assign.c -o assign.o
gcc -I"C:/PROGRA~1/R/R-44~1.1/include" -DNDEBUG     -I"C:/rtools44/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -fopenmp -std=c99 -O3 -pipe -Wall -pedantic -Wstrict-prototypes -isystem /usr/share/R/include -DWIN32 -fno-common -c between.c -o between.o
...
gcc -I"C:/PROGRA~1/R/R-44~1.1/include" -DNDEBUG     -I"C:/rtools44/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -fopenmp -std=c99 -O3 -pipe -Wall -pedantic -Wstrict-prototypes -isystem /usr/share/R/include -DWIN32 -fno-common -c reorder.c -o reorder.o
In file included from C:/PROGRA~1/R/R-44~1.1/include/R.h:71,
                 from data.table.h:3,
                 from nafill.c:1:
C:/PROGRA~1/R/R-44~1.1/include/R_ext/Complex.h:80:6: warning: ISO C99 doesn't support unnamed structs/unions [-Wpedantic]
   80 |     };
      |      ^
gcc -I"C:/PROGRA~1/R/R-44~1.1/include" -DNDEBUG     -I"C:/rtools44/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -fopenmp -std=c99 -O3 -pipe -Wall -pedantic -Wstrict-prototypes -isystem /usr/share/R/include -DWIN32 -fno-common -c shift.c -o shift.o

The different/unique compiler flags are:

R CMD INSTALL
-O2  -mfpmath=sse -msse2 -mstackrealign

cc()
-fopenmp -std=c99 -O3 -pipe -pedantic -Wstrict-prototypes -isystem /usr/share/R/include -DWIN32 -fno-common

I guess the issue comes from using -std=c99, I wonder if we can remove that?
more generally, why are the cc() compiler flags so different from the R CMD INSTALL compiler flags? is that desirable for us for some reason? (If there is no strong reason for the difference, I would suggest changing cc flags to match R CMD INSTALL flags)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions