Greetings, Brian Inglis!

> On 2021-01-04 18:34, Roger Kaufman wrote:
>> When I cross compile the following program, opening /dev/null fails and 
>> instead 
>> the whole install path of /cygwin64/dev/null is visible.
>> 
>> Is there a way to make fopen respect / as the root directory in a cross 
>> compiled 
>> program for windows?
>> 
>> example output...
>> 
>> Roger@interocitor:~
>> $ x86_64-w64-mingw32-g++ -o writenull.exe write2null.cc
>> 
>> Roger@interocitor:~
>> $ writenull.exe
>> /dev/null did not succeed
>> 
>> Roger@interocitor:~
>> $ gcc -o writenull write2null.cc
>> 
>> Roger@interocitor:~
>> $ writenull
>> /cygwin64/dev/null did not succeed
>> 
>> C Code that was compiled...
>> 
>> #include <cstdio>
>> 
>> int main(int argc, char **argv)
>> {
>>    FILE *errfile1 = fopen("/dev/null", "w");
>>    if (!errfile1) // must be a valid pointer
>>      errfile1 = stderr;
>> 
>>    FILE *errfile2 = fopen("/cygwin64/dev/null", "w");
>>    if (!errfile2) // must be a valid pointer
>>      errfile2 = stderr;
>> 
>>    fprintf(errfile1, "/dev/null did not succeed\n");
>>    fprintf(errfile2, "/cygwin64/dev/null did not succeed\n");
>> 
>>    return 0;
>> }

> It's a Windows program - it can do whatever you program it to do!
> On Windows the device is NUL, the root is the drive root C:\,

%SystemDrive%\ to be precise. Even though it IS C:\ in majority of cases, it
is not necessarily true all the time.

> and anything else depends on the Windows subsystem.

> To do otherwise you have to program it to emulate the Cygwin emulation,
> or build it as a Cygwin program using the Cygwin toolchain.



-- 
With best regards,
Andrey Repin
Wednesday, January 6, 2021 0:03:57

Sorry for my terrible english...
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to