delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/01/04/20:35:00

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BF07F3858021
Authentication-Results: sourceware.org; dmarc=none (p=none dis=none)
header.from=interocitors.com
Authentication-Results: sourceware.org;
spf=fail smtp.mailfrom=rogerkaufman AT interocitors DOT com
X-Authority-Reason: nr=8
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=interocitors.com; s=default; h=Content-Transfer-Encoding:Content-Type:
MIME-Version:Date:Message-ID:Subject:From:To:Sender:Reply-To:Cc:Content-ID:
Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:
List-Subscribe:List-Post:List-Owner:List-Archive;
bh=Epb36qI4UyRpp2wJlLOWGOGClVRxhy3Y/eOKOFf0Eag=; b=kYuTbpc5oh+9xlW0Tr2x4WDx1/
F6Hb34XCzT3NiXB5VGwI0cvRPRAK1gBWCM2NZGUcngvzfaWA06xd+7lm1gYMqNFXZ8qZgfSP8h24D
D23gGuuex1rE5NwkMSEMioQ3H;
To: cygwin AT cygwin DOT com
From: Roger Kaufman <rogerkaufman AT interocitors DOT com>
Subject: Is it possible to define the root directory in a cross compiled
program
Message-ID: <48b833bd-547a-92eb-542e-b7da8e0d601b@interocitors.com>
Date: Mon, 4 Jan 2021 20:34:05 -0500
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.6.0
MIME-Version: 1.0
X-AntiAbuse: This header was added to track abuse,
please include it with any abuse report
X-AntiAbuse: Primary Hostname - host2043.hostmonster.com
X-AntiAbuse: Original Domain - cygwin.com
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - interocitors.com
X-BWhitelist: no
X-Source-IP: 207.44.76.119
X-Source-L: No
X-Exim-ID: 1kwbEc-003gkI-FW
X-Source:
X-Source-Args:
X-Source-Dir:
X-Source-Sender: 207.44.76.119.res-cmts.hol.ptd.net ([192.168.1.99])
[207.44.76.119]:49505
X-Source-Auth: rogerkaufman AT interocitors DOT com
X-Email-Count: 2
X-Source-Cap: aW50ZXJvY2k7aW50ZXJvY2k7aG9zdDIwNDMuaG9zdG1vbnN0ZXIuY29t
X-Local-Domain: yes
X-Spam-Status: No, score=3.0 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE,
RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NEUTRAL,
TXREP autolearn=no autolearn_force=no version=3.4.2
X-Spam-Level: **
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 1051YgpO027971

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 AT interocitor:~
$ x86_64-w64-mingw32-g++ -o writenull.exe write2null.cc

Roger AT interocitor:~
$ writenull.exe
/dev/null did not succeed


Roger AT interocitor:~
$ gcc -o writenull write2null.cc

Roger AT 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;
}
--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019