* [GCC][Windows] header file inclusion on windows
@ 2023-01-28 3:57 Mena Makary
2023-01-28 14:04 ` David Brown
0 siblings, 1 reply; 3+ messages in thread
From: Mena Makary @ 2023-01-28 3:57 UTC (permalink / raw)
To: gcc-help
[-- Attachment #1: Type: text/plain, Size: 634 bytes --]
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?
Appreciating your support,
Regards,
Mina Makary
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [GCC][Windows] header file inclusion on windows
2023-01-28 3:57 [GCC][Windows] header file inclusion on windows Mena Makary
@ 2023-01-28 14:04 ` David Brown
2023-01-28 17:38 ` NightStrike
0 siblings, 1 reply; 3+ messages in thread
From: David Brown @ 2023-01-28 14:04 UTC (permalink / raw)
To: gcc-help
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [GCC][Windows] header file inclusion on windows
2023-01-28 14:04 ` David Brown
@ 2023-01-28 17:38 ` NightStrike
0 siblings, 0 replies; 3+ messages in thread
From: NightStrike @ 2023-01-28 17:38 UTC (permalink / raw)
To: David Brown; +Cc: gcc-help
On Sat, Jan 28, 2023 at 9:04 AM David Brown <david.brown@hesbynett.no> wrote:
> Another possibility is to run the compilation using a Cygwin
> environment, rather than more common mingw gcc builds. Under Cygwin,
> filenames are case sensitive.
I vaguely recall that years ago, Windows had an option to make an
entire volume case sensitive as part of its posix compatibility
efforts. Googling only reveals results related to a newer w10 option
to turn it on at a per-directory level. Either of those options might
be useful here for the user.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-28 17:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-28 3:57 [GCC][Windows] header file inclusion on windows Mena Makary
2023-01-28 14:04 ` David Brown
2023-01-28 17:38 ` NightStrike
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).