From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by sourceware.org (Postfix) with ESMTPS id 534BD3858D20 for ; Sat, 28 Jan 2023 14:04:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 534BD3858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=hesbynett.no Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=m.gmane-mx.org Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1pLloU-0004Is-9l for gcc-help@gcc.gnu.org; Sat, 28 Jan 2023 15:04:14 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: gcc-help@gcc.gnu.org From: David Brown Subject: Re: [GCC][Windows] header file inclusion on windows Date: Sat, 28 Jan 2023 15:04:08 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Content-Language: en-GB In-Reply-To: X-Spam-Status: No, score=-3031.2 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 28/01/2023 04:57, Mena Makary via Gcc-help wrote: > Hello GCC Help Team, > > Could you please support on the following C code example: > > #include "header.h" /* Proper file name like on windows file system, No > error is expected */ > #include "Header.h" /* Same file but H letter is camelcased by mistake, > Error is expected */ > #include "header.h " /* Same file but a space is added before end of file > inclusion by mistake, Error is expected */ > > The problem here is that the above two issues are not detected by GCC > on windows, while could be detected on Linux. > Is there any compiler option/flag enables GCC to detect such issues on > Windows? > I think this is inevitable for Windows. The compiler will ask for the header by trying to open a file called "header.h", "Header.h" or "header.h ", and the OS will give them file, because on Windows these all refer to the same file due to case-insensitive and space-striping names. So the compiler has no way to report this as an issue - because on Windows, it is /not/ an error. It is the expected behaviour of the system. In theory, I suppose, the compiler could ask for a details of the file or a directory listing, and compare the stored name (as file names are case-preserving in Windows) to the name requested by the pre-processor. But that would be a lot of extra work for no purpose for a compiler, and would break code that currently compiles fine on Windows. I don't know what you are aiming to do here. But one possibility is to use one of the "-M" options for gcc to create a "make" dependency file that lists the headers included by the file. A small Python script could parse that, read the true filename for the file on the Windows filesystem, and compare them. Another possibility is to run the compilation using a Cygwin environment, rather than more common mingw gcc builds. Under Cygwin, filenames are case sensitive.