Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Make include statement case insensitive
Forum Updated to NodeBB v4.3 + New Features

Make include statement case insensitive

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
10 Posts 4 Posters 886 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    angela2016
    wrote on last edited by
    #1

    Hi,

    I've had to move my projects to a different folder. Now when I try to build the projects Qt Creator complains when the include statement has the wrong case. So
    #include "dbPanelSessionabstract.h"
    won't work but
    #include "dbpanelsessionabstract.h"
    does.

    I understand that technically this is probably correct because the file itself is lower case but this has never been an issue so far and if I have to change everything I'm going to die.

    Is there a way to make Qt Creator ignore case sensitivity here? I'm on Linux. Thanks.

    Best wishes,
    Angela

    JonBJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      This is not a QtCreator problem - it's simply wrong on case-sensitive filesystems (like most filesystems on linux). So fix your include statement or rename your file.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher moved this topic from General and Desktop on
      • A angela2016

        Hi,

        I've had to move my projects to a different folder. Now when I try to build the projects Qt Creator complains when the include statement has the wrong case. So
        #include "dbPanelSessionabstract.h"
        won't work but
        #include "dbpanelsessionabstract.h"
        does.

        I understand that technically this is probably correct because the file itself is lower case but this has never been an issue so far and if I have to change everything I'm going to die.

        Is there a way to make Qt Creator ignore case sensitivity here? I'm on Linux. Thanks.

        Best wishes,
        Angela

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @angela2016
        As @Christian-Ehrlicher has said this is C++ #include behaviour (and everything else) on a case-sensitive file system, like Linux (but not Windows) usually is.

        because the file itself is lower case but this has never been an issue so far

        Then this would never have worked as-is on a Linux file system. Go back and look at where you copied the files from. Is it mixed-case there or lower-case only? You are likely in one of three situations:

        • The original is a Linux file system and the files are mixed-case. Then your Linux-to-Linux copy should retain case. If you claim this is the situation but the mixed-case is not retained then something is wrong in how you copy.
        • The original is, say, a Windows file system and the files are mixed-case there. Then go find why your copy changes to lower-case and fix that.
        • The original is, say, Windows and the files there are all lower-case. It will compile under Windows without you noticing that the cases of the files and the #includes differ but will never work under Linux. Since the #include code expects the filenames to be in mixed-case there is something wrong about how you originally got the files into Windows in the first place, they should always have been mixed-case even under Windows.
        SGaistS A 2 Replies Last reply
        0
        • JonBJ JonB

          @angela2016
          As @Christian-Ehrlicher has said this is C++ #include behaviour (and everything else) on a case-sensitive file system, like Linux (but not Windows) usually is.

          because the file itself is lower case but this has never been an issue so far

          Then this would never have worked as-is on a Linux file system. Go back and look at where you copied the files from. Is it mixed-case there or lower-case only? You are likely in one of three situations:

          • The original is a Linux file system and the files are mixed-case. Then your Linux-to-Linux copy should retain case. If you claim this is the situation but the mixed-case is not retained then something is wrong in how you copy.
          • The original is, say, a Windows file system and the files are mixed-case there. Then go find why your copy changes to lower-case and fix that.
          • The original is, say, Windows and the files there are all lower-case. It will compile under Windows without you noticing that the cases of the files and the #includes differ but will never work under Linux. Since the #include code expects the filenames to be in mixed-case there is something wrong about how you originally got the files into Windows in the first place, they should always have been mixed-case even under Windows.
          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @JonB Third option: macOS is by default case insensitive.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @SGaist And I thought it was supposed to be Linux or just like it....

            SGaistS 1 Reply Last reply
            0
            • JonBJ JonB

              @SGaist And I thought it was supposed to be Linux or just like it....

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by SGaist
              #6

              @JonB not it's a Unix like. If anything, it's closer to BSD.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @SGaist ...And all flavors of Unix, including BSD, have always been case-sensitive, of course... ;-) But we digress from OP.

                1 Reply Last reply
                0
                • JonBJ JonB

                  @angela2016
                  As @Christian-Ehrlicher has said this is C++ #include behaviour (and everything else) on a case-sensitive file system, like Linux (but not Windows) usually is.

                  because the file itself is lower case but this has never been an issue so far

                  Then this would never have worked as-is on a Linux file system. Go back and look at where you copied the files from. Is it mixed-case there or lower-case only? You are likely in one of three situations:

                  • The original is a Linux file system and the files are mixed-case. Then your Linux-to-Linux copy should retain case. If you claim this is the situation but the mixed-case is not retained then something is wrong in how you copy.
                  • The original is, say, a Windows file system and the files are mixed-case there. Then go find why your copy changes to lower-case and fix that.
                  • The original is, say, Windows and the files there are all lower-case. It will compile under Windows without you noticing that the cases of the files and the #includes differ but will never work under Linux. Since the #include code expects the filenames to be in mixed-case there is something wrong about how you originally got the files into Windows in the first place, they should always have been mixed-case even under Windows.
                  A Offline
                  A Offline
                  angela2016
                  wrote on last edited by
                  #8

                  @JonB I copied the files from a USB stick (FAT) to a hard disc (NTFS). The names of the files weren't changed (all lower case). The includes were sometimes mix cased. I used to compile on both Windows and Linux, but for a year or so only on Linux and I have completely rebuilt the project multiple times.

                  I have now written another program to help me fix the file names, but I'm still curious as to why compiling on Linux worked before.

                  JonBJ 1 Reply Last reply
                  0
                  • A angela2016

                    @JonB I copied the files from a USB stick (FAT) to a hard disc (NTFS). The names of the files weren't changed (all lower case). The includes were sometimes mix cased. I used to compile on both Windows and Linux, but for a year or so only on Linux and I have completely rebuilt the project multiple times.

                    I have now written another program to help me fix the file names, but I'm still curious as to why compiling on Linux worked before.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #9

                    @angela2016
                    FAT is what I call Windows, i.e. it's for Windows and is case-insensitive. That means the file system with some file.h (your all lower case) file will happily supply that when asked for it in any case, so e.g. #include "FiLe.h" (your mixed case) will find it. If you compiled your source on that file system format files there would match any case in the source includes.

                    The moment you copy that to NTFS the situation changes. NTFS, unlike FAT, is case-sensitive. However, Windows effectively treats it as case-insensitive, in that when it creates/opens files Windows does work to make creating "FiLe.h" overwrite an existing "file.h" and opening "FiLe.h" will open an existing "file.h". So it is the Windows OS, not the NTFS file system, which effectively enforces case-insensitivity. https://en.wikipedia.org/wiki/Case_sensitivity :

                    the FAT file systems became case-preserving as an extension of supporting long filenames.[8] Later Windows file systems such as NTFS are internally case-sensitive, and a readme.txt and a Readme.txt can coexist in the same directory. However, for practical purposes filenames behave as case-insensitive as far as users and most software are concerned.[9] This can cause problems for developers or software coming from Unix-like environments, similar to the problems with macOS case-insensitive file systems.

                    But when you access NTFS from Linux, a case-sensitive OS, Linux treats FiLe.h amd file.h as quite distinct, as it would on any other file system such as ext4. So then #include "FiLe.h" will fail if on NTFS the file is file.h.

                    TBH I regard accessing FAT from Linux as "inappropriate", and could cause problems. Accessing NTFS from Linux is OK if you really have to BUT not if you mix that with writing to it from Windows.

                    So.... Your original problem is that you have source code with #include "dbPanelSessionabstract.h" but the file on your original FAT is, apparently, dbpanelsessionabstract.h. This will go wrong once you copy it off FAT. The issue is how did it ever come to be dbpanelsessionabstract.h in the first place? This is wrong. Presumably the author of the .cpps had the file on disk as dbPanelSessionabstract.h at the time they wrote the #include, whatever file system it was on. Some copy changed that to all lower-case, and that is where the problem stems from.

                    Summary: Your code would compile as-is against a FAT file system. Now that you are using NTFS (or ext4) with Linux you either have to change (or re-copy) the files on disk to match the #include mixed-case or you have to change all the #include lines to match the case on disk.

                    A 1 Reply Last reply
                    5
                    • JonBJ JonB

                      @angela2016
                      FAT is what I call Windows, i.e. it's for Windows and is case-insensitive. That means the file system with some file.h (your all lower case) file will happily supply that when asked for it in any case, so e.g. #include "FiLe.h" (your mixed case) will find it. If you compiled your source on that file system format files there would match any case in the source includes.

                      The moment you copy that to NTFS the situation changes. NTFS, unlike FAT, is case-sensitive. However, Windows effectively treats it as case-insensitive, in that when it creates/opens files Windows does work to make creating "FiLe.h" overwrite an existing "file.h" and opening "FiLe.h" will open an existing "file.h". So it is the Windows OS, not the NTFS file system, which effectively enforces case-insensitivity. https://en.wikipedia.org/wiki/Case_sensitivity :

                      the FAT file systems became case-preserving as an extension of supporting long filenames.[8] Later Windows file systems such as NTFS are internally case-sensitive, and a readme.txt and a Readme.txt can coexist in the same directory. However, for practical purposes filenames behave as case-insensitive as far as users and most software are concerned.[9] This can cause problems for developers or software coming from Unix-like environments, similar to the problems with macOS case-insensitive file systems.

                      But when you access NTFS from Linux, a case-sensitive OS, Linux treats FiLe.h amd file.h as quite distinct, as it would on any other file system such as ext4. So then #include "FiLe.h" will fail if on NTFS the file is file.h.

                      TBH I regard accessing FAT from Linux as "inappropriate", and could cause problems. Accessing NTFS from Linux is OK if you really have to BUT not if you mix that with writing to it from Windows.

                      So.... Your original problem is that you have source code with #include "dbPanelSessionabstract.h" but the file on your original FAT is, apparently, dbpanelsessionabstract.h. This will go wrong once you copy it off FAT. The issue is how did it ever come to be dbpanelsessionabstract.h in the first place? This is wrong. Presumably the author of the .cpps had the file on disk as dbPanelSessionabstract.h at the time they wrote the #include, whatever file system it was on. Some copy changed that to all lower-case, and that is where the problem stems from.

                      Summary: Your code would compile as-is against a FAT file system. Now that you are using NTFS (or ext4) with Linux you either have to change (or re-copy) the files on disk to match the #include mixed-case or you have to change all the #include lines to match the case on disk.

                      A Offline
                      A Offline
                      angela2016
                      wrote on last edited by
                      #10

                      @JonB Interesting, thanks. I always thought of NTFS as case insensitive per se.

                      1 Reply Last reply
                      0
                      • A angela2016 has marked this topic as solved on

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved