jakobbossek / dandy

Wrapper for sampling methods in R and approximate star discrepancy calculation
GNU General Public License v3.0
4 stars 1 forks source link

Fix C warnings #4

Open jakobbossek opened 4 years ago

jakobbossek commented 4 years ago

I have no idea how to solve incompatible pointer types passing warnings.

── R CMD check ───────────────────────────────────────────────────────────────── ─ using log directory ‘/private/var/folders/lr/g4jxbpys6z54qrs4ppyln72c0000gn/T/rcheck-sampling-20191218-222222/sampling.Rcheck’ (339ms) ─ using R version 3.5.2 (2018-12-20) ─ using platform: x86_64-apple-darwin15.6.0 (64-bit) ─ using session charset: UTF-8 ✔ checking for file ‘sampling/DESCRIPTION’ ... ─ this is package ‘sampling’ version ‘1.0.0.0000’ ─ package encoding: UTF-8 ✔ checking package namespace information ✔ checking package dependencies (6.1s) ✔ checking if this is a source package ✔ checking if there is a namespace ✔ checking for executable files ... ✔ checking for hidden files and directories ✔ checking for portable file names ✔ checking for sufficient/correct file permissions W checking whether package ‘sampling’ can be installed (3.7s) Found the following significant warnings: bz_discr.c:85:48: warning: incompatible pointer types passing 'int (double , double )' to parameter of type 'int ( _Nonnull)(const void , const void )' [-Wincompatible-pointer-types] dem_discr.c:101:59: warning: incompatible pointer types passing 'int (double , double )' to parameter of type 'int ( _Nonnull)(const void , const void )' [-Wincompatible-pointer-types] dem_discr.c:229:48: warning: incompatible pointer types passing 'int (double , double )' to parameter of type 'int ( _Nonnull)(const void , const void )' [-Wincompatible-pointer-types] dem_discr.c:230:44: warning: incompatible pointer types passing 'int (double , double )' to parameter of type 'int ( _Nonnull)(const void , const void )' [-Wincompatible-pointer-types] dem_discr.c:292:52: warning: incompatible pointer types passing 'int (double , double )' to parameter of type 'int ( _Nonnull)(const void , const void *)' [-Wincompatible-pointer-types] See ‘/private/var/folders/lr/g4jxbpys6z54qrs4ppyln72c0000gn/T/rcheck-sampling-20191218-222222/sampling.Rcheck/00install.out’ for details. ✔ checking installed package size ... ✔ checking package directory ✔ checking DESCRIPTION meta-information (369ms) ✔ checking top-level files ✔ checking for left-over files ✔ checking index information ✔ checking package subdirectories ... ✔ checking R files for non-ASCII characters ... ✔ checking R files for syntax errors ... ✔ checking whether the package can be loaded ... ✔ checking whether the package can be loaded with stated dependencies ... ✔ checking whether the package can be unloaded cleanly ... ✔ checking whether the namespace can be loaded with stated dependencies ... ✔ checking whether the namespace can be unloaded cleanly ... ✔ checking loading without being on the library search path ... ✔ checking dependencies in R code (350ms) ✔ checking S3 generic/method consistency (533ms) ✔ checking replacement functions ... ✔ checking foreign function calls ... ✔ checking R code for possible problems (1.3s) ✔ checking Rd files ... ✔ checking Rd metadata ... ✔ checking Rd cross-references ... ✔ checking for missing documentation entries ... ✔ checking for code/documentation mismatches (752ms) ✔ checking Rd \usage sections (788ms) ✔ checking Rd contents ... ✔ checking for unstated dependencies in examples ... ✔ checking line endings in C/C++/Fortran sources/headers W checking compiled code ... File ‘sampling/libs/sampling.so’: Found ‘_stderrp’, possibly from ‘stderr’ (C) Objects: ‘TA_common.o’, ‘TA_shrink_bardelta.o’, ‘TA_shrink_delta.o’, ‘bz_discr.o’, ‘dem_discr.o’, ‘simplediscr.o’ Found ‘stdoutp’, possibly from ‘stdout’ (C) Objects: ‘TA_shrink_bardelta.o’, ‘TA_shrink_delta.o’ Found ‘_abort’, possibly from ‘abort’ (C) Objects: ‘TA_common.o’, ‘dem_discr.o’ Found ‘_rand’, possibly from ‘rand’ (C) Object: ‘TA_common.o’ Found ‘_random’, possibly from ‘random’ (C) Objects: ‘TA_common.o’, ‘simple_discr.o’

Compiled code should not call entry points which might terminate R nor write to stdout/stderr instead of to the console, nor use Fortran I/O nor system RNGs.

jakobbossek commented 4 years ago

Related to the pointer stuff: https://cboard.cprogramming.com/c-programming/24898-problem-incompatible-pointer-type.html

jakobbossek commented 4 years ago

I have no time to do this now. As everything works very well this is of minor importance now; just prevents us from sending the package to CRAN.

hkumar6 commented 4 years ago

The warnings here:

bz_discr.c:85:48: warning: incompatible pointer types passing 'int (double **, double *)' to parameter of type 'int ( _Nonnull)(const void *, const void *)' [-Wincompatible-pointer-types]
dem_discr.c:101:59: warning: incompatible pointer types passing 'int (double *, double )' to parameter of type 'int ( _Nonnull)(const void *, const void *)' [-Wincompatible-pointer-types]
dem_discr.c:229:48: warning: incompatible pointer types passing 'int (double **, double *)' to parameter of type 'int ( _Nonnull)(const void *, const void *)' [-Wincompatible-pointer-types]
dem_discr.c:230:44: warning: incompatible pointer types passing 'int (double **, double *)' to parameter of type 'int ( _Nonnull)(const void *, const void *)' [-Wincompatible-pointer-types]
dem_discr.c:292:52: warning: incompatible pointer types passing 'int (double **, double *)' to parameter of type 'int ( _Nonnull)(const void *, const void *)' [-Wincompatible-pointer-types]

are fixed by the uncommenting these parts of the code:

https://github.com/jakobbossek/dandy/blob/4a354a747897198681812ffcf75e5897cebd3de5/src/bz_discr.c#L32

https://github.com/jakobbossek/dandy/blob/4a354a747897198681812ffcf75e5897cebd3de5/src/bz_discr.h#L11

I also checked it and it works. So you already have the solution to this. 👍

jakobbossek commented 4 years ago

@hkumar6 Thank you so much! 😀 I really appreciate your support.

hkumar6 commented 4 years ago

@jakobbossek You're welcome! I also have an idea of how to fix these warnings/errors:

File ‘sampling/libs/sampling.so’:
Found ‘___stderrp’, possibly from ‘stderr’ (C)
Objects: ‘TA_common.o’, ‘TA_shrink_bardelta.o’,
‘TA_shrink_delta.o’, ‘bz_discr.o’, ‘dem_discr.o’,
‘simple_discr.o’
Found ‘___stdoutp’, possibly from ‘stdout’ (C)
Objects: ‘TA_shrink_bardelta.o’, ‘TA_shrink_delta.o’
Found ‘_abort’, possibly from ‘abort’ (C)
Objects: ‘TA_common.o’, ‘dem_discr.o’
Found ‘_rand’, possibly from ‘rand’ (C)
Object: ‘TA_common.o’
Found ‘_random’, possibly from ‘random’ (C)
Objects: ‘TA_common.o’, ‘simple_discr.o’

Compiled code should not call entry points which might terminate R nor
write to stdout/stderr instead of to the console, nor use Fortran I/O
nor system RNGs.

These errors occur because the indicated native C functions are used which causes conflicts when launched inside an R session. That is what the last line of the error explains. The fix is to use Rcpp headers and the corresponding Rcpp-API instead of the native C calls. If you don't mind and don't have time for this, I could make a fix and create a pull request. 😃

jakobbossek commented 4 years ago

Yep, I know how to fix these warnings, but I was too lazy to implement the necessary changes 😅

If you don't mind and don't have time for this, I could make a fix and create a pull request. 😃

Would be awesome! Thanks!