This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

errno issue with cross gcc using newlib


Hi All,

I have come across a strange behaviour using gcc cross compiler (host:
linux, target: cygwin). I am using the cygwin header files and lib files
while making the compiler. (Cygwin uses newlib instaed of libc). 

Consider this short code:

   int fd = ::open("/tmp/errnotest", O_RDONLY | O_BINARY);
    
    if (fd == -1) {
	std::cerr << "open failed, errno=" << errno << ", strerror=" <<
strerror(errno) << std::endl;
	std::cerr << "open failed, errno=" << errno << ", strerror=" <<
strerror(errno) << std::endl;
    }

I have compiled this code using a cross gcc build on host linux using
target cygwin.

If I build the cross compiler by providing --enable-threads=single option
in the configure stage, following is the output :

open failed, errno=2, strerror=No such file or directory
open failed, errno=2, strerror=No such file or directory
 
This is of course expected.

Hoewever if I build the cross compiler by providing --enable-threads=posix
option in the configure stage, the output is as follows :

open failed, errno=2, strerror=No such file or directory
open failed, errno=0, strerror=No error

That is , after the first call to errno, it is reset!!

Has anyone else experiened this before? Can anyone please help find out
what exactly is going wrong?

Regards,

Anurag

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]