Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-17235

windows, clang code model: clang warnings (on system headers and command line options)

    XMLWordPrintable

Details

    Description

      When opening a C++ file that include windows.h, errors are found in winnt.h probably due to missing preprocessor definition :

      winnt.h:135:2: error: "No Target Architecture"
      wavePlayUDP.cpp:1:10: note: in file included from D:\wavePlayer\win\wavePlayUDP.cpp:1:
      windows.h:155:10: note: in file included from C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE/windows.h:155:
      windef.h:177:10: note: in file included from C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\windef.h:177:
      

      See also in attachment clang_code_model_winnt.png.

      When adding -D_M_AMD64 -Wno-invalid-token-paste or -D_M_AMD64 -isystem to clang code model warnings configuration, there is no more warnings.
      -Wno-invalid-token-paste and -isystem are suggested in the llvm bug 18822 :

      We already have an compatibility for hack for this, added in r108624:

      Add another terrible VC++ compatibility hack: allow users to
      allow invalid token pastes (when in -fms-extensions mode)
      with -Wno-invalid-token-paste

      It added this diagnostic:
      [...]

      So, this is a warning that's sort of also an error. You can suppress it with -Wno-invalid-token-paste, but a much better way to do it is to use -isystem to provide paths to system headers like windows.h, in which case clang will suppress all warnings in those files by default.

      I think these preprocessor definitions should be always set by default on Windows by clang as the clang.exe set _M_AMD64 on windows for example. For example with Clang 64 bits for Windows :

      $ clang -dM -E - < /dev/null | grep _M_AMD64
      #define _M_AMD64 100
      

      Also, when opening a C project, a warning shows

      0:0: error: invalid argument '-std=c++11' not allowed with 'C/ObjC'

      See also the screenshot clang_code_model_c_file.png.


      For additional information, all these warnings are using cmake and Microsoft Visual C++ Compiler 12.0 (x86_amd64) compiler from VS 2013.

      Attachments

        Activity

          People

            yvvan Ivan Donchevskii
            amurzeau Alexis Murzeau
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: