Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C warnings #4

Open
jakobbossek opened this issue Dec 18, 2019 · 6 comments
Open

Fix C warnings #4

jakobbossek opened this issue Dec 18, 2019 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@jakobbossek
Copy link
Owner

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’,
‘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.

@jakobbossek
Copy link
Owner Author

@jakobbossek
Copy link
Owner Author

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.

@jakobbossek jakobbossek added the help wanted Extra attention is needed label Dec 19, 2019
@hkumar6
Copy link

hkumar6 commented Sep 16, 2020

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:

// int cmpkeyk(const void *pt1, const void *pt2)

//int cmpkeyk(const void *pt1, const void *pt2);

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

@jakobbossek
Copy link
Owner Author

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

@hkumar6
Copy link

hkumar6 commented Sep 17, 2020

@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
Copy link
Owner Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants