LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Making LabWindows use Clang 19?

Is there a tutorial anywhere about getting a new/modern Clang set up in LabWindows?

 

I see LabWindows has options for different compilers, and has templates for them -- but the 3.3 won't work with the current Clang.

 

I played with this a bit trying to point it to the new Clang, and update the Warning Level command line options, but still don't have it all going. It cannot find things like utility.h or windows.h.

 

Tips apprecaite.

0 Kudos
Message 1 of 3
(87 Views)

My research so far:

 

Clang 19 download: https://github.com/llvm/llvm-project/releases/tag/llvmorg-19.1.0 

 

I downloaded "LLVM-19.1.0-win64.exe" which installs clang.exe here:

 

C:\Program Files\LLVM\bin

 

In LabWindows:

 

  • Options -> Build Options : Build Process Options tab
    • Active 64-bit compiler: "New..."
      • Compiler for 64-Bit Release Configurations
      • New
      • New 64-Bit Configuration
        • Configuration Name: "Clang 19 64-bit" or whatever
        • Destination File: "clang19-64bit" and browser to where it will create this ".ecc" config file.
        • Template Configuration: "clang 3.3 (clang.exe) (template)"
        • OK
      • Select your new profile and "Edit..."
      • Compiler Setup - Clang 19 64-Bit
        • Disk File (ecc): cannot be changed after you make it?
        • Configuration Name: "Clang 19 64-Bit" or whatever
        • Warning Level: (...) - these have clang 3.3 flags and they conflict with modern clang flags. Here is what CoPilot suggested I change them to:
          • Default Warnings: -Wall -Wno-microsoft -Wno-unknown-pragmas
          • More Warnings: -Wall -Wextra -Wno-microsoft -Wno-unknown-pragmas -fdiagnostics-show-option
        • "Advanced..." button
          • Compiler Path: browse to the clang.exe. Mine was "C:\Program Files\LLVM\bin\clang.exe"
          • Compatibility Flags: "-cc1 -triple x86_64-pc-windows-msvc -D_M_AMD64 -emit-obj -ffreestanding -fms-extensions -fms-compatibility-version=19.0 -mms-bitfields -fno-caret-diagnostics" (someone please check these; using what CoPilot suggested)
          • Environmental Setup Batch File: There is a "clang.bat" file located in "c:\program files (x86)\national instruments\cvi2017\bin\clang\3.3\clang.bat". I just copied it somewhere else (where I put the .ecc config file) and browse to it.
          • Include Path: Important: Remove the space between "-I $PATH" so it is "-I$PATH". Without that, it won't find any of the header files and you get errors.

For the batch file, I just used the default. It checks for the existence of the %CVIDIR% environment variable, then checks to see if "%CVIDIR%\include\clang" and "%CVIDIR%\include\clang\3.3" exist. Ideally, this would need to be updated for the new clang header files.

 

BUT, the help file entry "Factors to Consider When Creating or Editing a Compiler Configuration" has this note:

 

Include Paths

    —You must use the LabWindows/CVI include paths, not the external compiler include paths. It might be necessary to set a flag to instruct the external compiler to disregard its include paths. If you must use an include file the external compiler provides, add that include file to the LabWindows/CVI project.

Can this NOT use the updated C header files with Clang 19? Once I did these steps, I can build and link. I do not know how to verify it is using the clang.exe I pointed it to, versus the built-in 3.3.

 

Is there a write-up on how to do this?

Message 2 of 3
(74 Views)

I would try to see what the compiler is defining for __STDC_VERSION__. With Clang 19.1, it looks like it should be 202311 (C23), but you could end up with 201710 (C17). The version shipping with CVI 2020 is defined as 199901 (C99)

 

char szMessage[48];
sprintf (szMessage, "STDC Version: %lu", __STDC_VERSION__);
MessagePopup ("STC Version", szMessage);

Message 3 of 3
(24 Views)