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

Carmen M. Livi carmen.livi at ifom.eu
Tue Feb 20 20:56:45 CET 2018


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:
> Prova ad aggiungere
>
> #include <windows.h>
> #include <sys/locking.h>
>
>
>> On 19 Feb 2018, at 15:07, Carmen M. Livi<carmen.livi at ifom.eu>  wrote:
>>
>> Ciao Mauro,
>> Posso disturbarti un secondo di pomeriggio e scendere un attimo? Ho un problema con C... cioe' io e linux no, ma Windows.
>> Sulle nostre macchine compila senza problemi ma su Windows mi da un errore.
>>
>> Lancio il seguente commando:
>> g++ -m64 -std=gnu++11 -I"/lustre/home/clivi/programs/R-devel/include" -DNDEBUG  -I"/lustre/home/clivi/programs/R-devel/library/Rcpp/include/" -I"/lustre/home/clivi/programs/R-devel/library/BH/include/"   -I"/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include"  -I./ -D_FASTMAP -DMAQ_LONGREADS -lbz2     -O2 -Wall  -mtune=core2 -c bed2vector.cpp -o bed2vector.o
>> Allegato il codice da eseguire.
>>
>> l messaggio di errore:
>> * installing *source* package 'spp' ...
>> ** libs
>> Warning: this package has a non-empty 'configure.win' file,
>> so building only the main architecture
>>
>> d:/Compiler/gcc-4.9.3/mingw_64/bin/g++ -m64 -std=gnu++11 -I"D:/RCompile/recent/R-3.4.3/include" -DNDEBUG  -I"d:/RCompile/CRANpkg/lib/3.4/Rcpp/include" -I"d:/RCompile/CRANpkg/lib/3.4/BH/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"  -I./ -D_FASTMAP -DMAQ_LONGREADS -lbz2     -O2 -Wall  -mtune=core2 -c bed2vector.cpp -o bed2vector.o
>> In file included from D:/RCompile/recent/R-3.4.3/include/Rdefines.h:37:0,
>>                   from bed2vector.cpp:22:
>> D:/RCompile/recent/R-3.4.3/include/R_ext/RS.h:55:0: warning: "ERROR" redefined
>>   #define ERROR   ),error(R_problem_buf);}
>>   ^
>> In file included from D:/Compiler/gcc-4.9.3/mingw_64/x86_64-w64-mingw32/include/windows.h:71:0,
>>                   from d:/Compiler/gcc-4.9.3/local330/include/bzlib.h:79,
>>                   from bed2vector.cpp:15:
>> D:/Compiler/gcc-4.9.3/mingw_64/x86_64-w64-mingw32/include/wingdi.h:75:0: note: this is the location of the previous definition
>>   #define ERROR 0
>>   ^
>> bed2vector.cpp: In function 'int get_bzline(BZFILE*, std::string&)':
>> bed2vector.cpp:48:11: warning: variable 'nBuf' set but not used [-Wunused-but-set-variable]
>>     int     nBuf;
>>             ^
>> bed2vector.cpp: In function 'SEXPREC* read_eland_mismatches(SEXP)':
>> bed2vector.cpp:654:11: warning: variable 'nm' set but not used [-Wunused-but-set-variable]
>>         int nm=0;
>>             ^
>> bed2vector.cpp: In function 'SEXPREC* read_eland_extended(SEXP, SEXP, SEXP)':
>> bed2vector.cpp:1074:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
>>         for(int i=0;i<str_nm.size();i++) {
>>                      ^
>> bed2vector.cpp: In function 'ssize_t getline_local(char**, size_t*, FILE*)':
>> bed2vector.cpp:2659:19:
>> error
>> : 'flockfile' was not declared in this scope
>>     flockfile(stream);
>>                     ^
>> bed2vector.cpp:2662:46:
>> error
>> : 'getc_unlocked' was not declared in this scope
>>     for (int ch = 0; (ch = getc_unlocked(stream)) != EOF;) {
>>                                                ^
>> bed2vector.cpp:2670:27:
>> error
>> : 'funlockfile' was not declared in this scope
>>           funlockfile(stream);
>>                             ^
>> bed2vector.cpp:2686:21:
>> error:
>>   'funlockfile' was not declared in this scope
>>     funlockfile(stream);
>>                       ^
>> make: *** [bed2vector.o] Error 1
>> Warning: running command 'make -f "Makevars.win" -f "D:/RCompile/recent/R-3.4.3/etc/x64/Makeconf" -f "D:/RCompile/recent/R-3.4.3/etc/x64/Makevars.site" -f "D:/RCompile/recent/R-3.4.3/share/make/winshlib.mk" CXX='$(CXX11) $(CXX11STD)' CXXFLAGS='$(CXX11FLAGS)' CXXPICFLAGS='$(CXX11PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX11LDFLAGS)' SHLIB_LD='$(SHLIB_CXX11LD)' SHLIB="spp.dll" WIN=64 TCLBIN=64 OBJECTS="bed2vector.o cdensum.o maqmap.o maqread.o peaks.o spp_init.o wdl.o"' had status 2
>> ERROR: compilation failed for package 'spp'
>> * removing 'd:/RCompile/CRANguest/R-release/lib/spp'
>> In R CMD INSTALL
>>
>> <bed2vector.cpp>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list