Skip to content
Prev 2430 / 12125 Next

[R-pkg-devel] header file for "flockfile" function under windows

Hi all,

I am using file-locking functions in C that can be found in the 
<stdio.h> in Unix

extern void flockfile (FILE *__stream) __THROW;
extern int ftrylockfile (FILE *__stream) __THROW __wur;
extern void funlockfile (FILE *__stream) __THROW;

When submitting to CRAN I have troubles with the win-builder.

<stdio.h> in windows does not contain those functions. But I found them 
in the <pthread_unistd.h>.
But even when including all possible header files for pthread like:*
*

*#include <windows.h>**#include <sys/locking.h>*
*#include <pthread_unistd.h>****#include <pthread.h>****#include <pthread_compat.h>****#include <pthread_signal.h>****#include <pthread_time.h>*

I am aways getting the same error from win-builder:

bed2vector.cpp:2667:19: error: 'flockfile' was not declared in this scope
    flockfile(stream);
                    ^
bed2vector.cpp:2670:46: error: 'getc_unlocked' was not declared in this scope
    for (int ch = 0; (ch = getc_unlocked(stream)) != EOF;) {
                                               ^
bed2vector.cpp:2678:27: error: 'funlockfile' was not declared in this scope
          funlockfile(stream);
                            ^
bed2vector.cpp:2694:21: error: 'funlockfile' was not declared in this scope
    funlockfile(stream);
                      ^

So the header files are there, but the functions are not defined. I am 
not an expert in C, but
have to submit a package that uses C-code. Does someone have more 
experience with this?

Thanks,
Carmen
On 19/02/2018 15:22, Mauro Donadello wrote: