Is __CC_ARM not defined in the MDK Eval Version?

I'm working on a simple project and trying to make it work for both STM32CubeIDE and Keil uVision.  Building in uVision, in *my* files __CC_ARM is not defined. If I manually define it on the Target1 Options C Compiler form, then I get a million errors says that it is already defined in *other* files. Other files meaning supplied things like

stm32f10x.h(483): warning: In file included from...

I can see that in "core_cm3.h" it is already defined (magically).

Ideas??

I noticed someone doing this:

#if defined(__CC_ARM) || defined(__ARMCC_VERSION)

  • And now I see that __GNUC__ is defined in the Keil eval version. Is this normal?

    IDE-Version:
    µVision V5.34.0.0
    Copyright (C) 2021 ARM Ltd and ARM Germany GmbH. All rights reserved.
    
    Tool Version Numbers:
    Toolchain:        MDK-Lite  Version: 5.34.0.0
    Toolchain Path:    C:\Keil_v5_MDK\ARM\ARMCLANG\Bin
    C Compiler:         ArmClang.exe        V6.16
    Assembler:          Armasm.exe        V6.16
    Linker/Locator:     ArmLink.exe        V6.16
    Library Manager:    ArmAr.exe        V6.16
    Hex Converter:      FromElf.exe        V6.16
    CPU DLL:               SARMCM3.DLL          V5.34.0.0
    Dialog DLL:         TCM.DLL              V1.48.0.0
    Target DLL:             STLink\ST-LINKIII-KEIL_SWO.dll      V3.0.8.0
    Dialog DLL:         TCM.DLL              V1.48.0.0
    
    

  • Code generation is set to "use default compiler version 6"

  • If I set Code Generation to "use default compiler version 5", then both of those are resolved (__GNUC_ is now undefined and __CC_ARM is defined), but that introduces a whole raft of other things that need to be downgraded in my code (for lack of a better word).

  • __GNUC__:
    Set when you specify the --gnu option. It is an integer that shows the current major version of the GNU mode being used.
    (In Keil this is set under Project -> Options For Target ->C/C++ tab, check "GNU extensions"

    __CC_ARM:
    Always set to 1 for the ARM compiler, even when you specify the --thumb option.

    See:
    www.keil.com/.../armcc_chr1359125007083.htm

    If you look in your code, did anyone undefine the  __CC_ARM? Maybe with a command like:
    www.keil.com/.../armcc_chr1359124947379.htm

    Note: nowadays, if you want to make sure your code works for Arm Compiler 5 only, we do something like:

    #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)

  • Hi,

    For v5:

    -c --cpu Cortex-M3 -D__EVAL -g -O0 --apcs=interwork --split_sections
    -I./RTE/Device/STM32F103C8

    For v6:

    -xc -std=c99 --target=arm-arm-none-eabi -mcpu=cortex-m3 -c
    -fno-rtti -funsigned-char -fshort-enums -fshort-wchar

    Pretty different haha. I'm just learning, but arm-arm-none-eabi is GCC, non?

  • No undefines are done in my code (I'm the only one here to blame). I did read that stuff. The control strings are totally different, but I guess you'd expect that with a different compiler. Any way to get away from GCC? I don't understand the origin of the control strings.

    I will open an older version of my project and compare in case something got clobbered on my end. At the moment I'm just selecting one compiler or the other using the drop-down and I wouldn't have even gone there had I not hit this issue.

  • Maybe this an MDK Lite thing. We're being kicked to the curb. :-(

  • Hi,

    I'm still confused gang.I'm still getting what looks to me like GCC and not Keil? My objective is to be able to conditionally compile slightly different code for each, as needed. So,

    I created a new project from scratch using C:\Keil_v5_MDK\UV4\UV4.exe  (File Version 5.34.0.0)

    I see, under default Target1 -> Options

    Arm Compiler: Use default compiler version 6

    The Compiler control string is:

    -xc -std=c99 --target=arm-arm-none-eabi -mcpu=cortex-m3 -c
    -fno-rtti -funsigned-char -fshort-enums -fshort-wchar
    -D__EVAL -gdwarf-3 -O1 -ffunction-sections -Weverything -Wno-packed -Wno-reserved-id-macro -Wno-unused-macros -Wno-documentation-unknown-command -Wno-documentation -Wno-license-management -Wno-parentheses-equality 
    -I./RTE/Device/STM32F103C8
    -I./RTE/_Target_1
    -IC:/Users/GB/AppData/Local/Arm/Packs/ARM/CMSIS/5.8.0/CMSIS/Core/Include
    -IC:/Users/GB/AppData/Local/Arm/Packs/Keil/STM32F1xx_DFP/2.3.0/Device/Include
    -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F10X_MD -D_RTE_
    -o ./Objects/*.o -MD

    The About box says:

    IDE-Version:
    µVision V5.34.0.0
    Copyright (C) 2021 ARM Ltd and ARM Germany GmbH. All rights reserved.
    
    License Information:
    Grant B
    LIC=----
    
    Tool Version Numbers:
    Toolchain:        MDK-Lite  Version: 5.34.0.0
    Toolchain Path:    C:\Keil_v5_MDK\ARM\ARMCLANG\Bin
    C Compiler:         ArmClang.exe        V6.16
    Assembler:          Armasm.exe        V6.16
    Linker/Locator:     ArmLink.exe        V6.16
    Library Manager:    ArmAr.exe        V6.16
    Hex Converter:      FromElf.exe        V6.16
    CPU DLL:               SARMCM3.DLL          V5.34.0.0
    Dialog DLL:         TCM.DLL              V1.48.0.0
    Target DLL:             UL2CM3.DLL           V1.163.9.0
    Dialog DLL:         TCM.DLL              V1.48.0.0
    
    

    The Build log:

    
    µVision Build Log
    
    Tool Versions:
    
    IDE-Version: µVision V5.34.0.0
    Copyright (C) 2021 ARM Ltd and ARM Germany GmbH. All rights reserved.
    License Information: Grant B, , LIC=----
     
    Tool Versions:
    Toolchain:       MDK-Lite  Version: 5.34.0.0
    Toolchain Path:  C:\Keil_v5_MDK\ARM\ARMCLANG\Bin
    C Compiler:      ArmClang.exe V6.16
    Assembler:       Armasm.exe V6.16
    Linker/Locator:  ArmLink.exe V6.16
    Library Manager: ArmAr.exe V6.16
    Hex Converter:   FromElf.exe V6.16
    CPU DLL:         SARMCM3.DLL V5.34.0.0
    Dialog DLL:      DCM.DLL V1.17.3.0
    Target DLL:      UL2CM3.DLL V1.163.9.0
    Dialog DLL:      TCM.DLL V1.48.0.0
     
    Project:
    
    D:\Grant4\STM32\STM32_Keil_v5_MDK\Dog\Dog.uvprojx
    Project File Date:  07/19/2021
    
    Output:
    
    *** Using Compiler 'V6.16', folder: 'C:\Keil_v5_MDK\ARM\ARMCLANG\Bin'
    Rebuild target 'Target 1'
    compiling main.c...
    assembling startup_stm32f10x_md.s...
    RTE/Device/STM32F103C8/system_stm32f10x.c(167): warning: no previous extern declaration for non-static variable 'AHBPrescTable' [-Wmissing-variable-declarations]
    __I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
                ^
    RTE/Device/STM32F103C8/system_stm32f10x.c(167): note: declare 'static' if the variable is not intended to be used outside of this translation unit
    __I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
        ^
    1 warning generated.
    compiling system_stm32f10x.c...
    linking...
    Program Size: Code=664 RO-data=252 RW-data=0 ZI-data=1632  
    ".\Objects\Dog.axf" - 0 Error(s), 1 Warning(s).
    
    Software Packages used:
    
    
    Package Vendor: ARM
                    http://www.keil.com/pack/ARM.CMSIS.5.8.0.pack
                    ARM.CMSIS.5.8.0
                    CMSIS (Common Microcontroller Software Interface Standard)
       * Component: CORE Version: 5.5.0
    
    Package Vendor: Keil
                    http://www.keil.com/pack/Keil.STM32F1xx_DFP.2.3.0.pack
                    Keil.STM32F1xx_DFP.2.3.0
                    STMicroelectronics STM32F1 Series Device Support, Drivers and Examples
       * Component: Startup Version: 1.0.0
    
    Collection of Component include folders:
    
      .\RTE\Device\STM32F103C8
      .\RTE\_Target_1
      C:\Users\GBeattie\AppData\Local\Arm\Packs\ARM\CMSIS\5.8.0\CMSIS\Core\Include
      C:\Users\GBeattie\AppData\Local\Arm\Packs\Keil\STM32F1xx_DFP\2.3.0\Device\Include
    
    Collection of Component Files used:
    
    
       * Component: ARM::CMSIS:CORE:5.5.0
    
       * Component: Keil::Device:Startup:1.0.0
          Source file:   Device\Source\ARM\STM32F1xx_OPT.s
          Source file:   Device\Source\system_stm32f10x.c
          Source file:   Device\Source\ARM\startup_stm32f10x_md.s
          Include file:  RTE_Driver\Config\RTE_Device.h
    Build Time Elapsed:  00:00:00
    
    

    My screen shows (I expected GCC not to be defined for a Keil compiler):

    Suggestions on how I can conditionally compile for Keil versus GCC?

  • As mentioned, when I change to Compiler Default version 5 things are the opposite:

  • Try using this as an reference:

    github.com/.../main.cpp

    In it they use 

    #ifdef __IS_COMPILER_GCC__

     

    -----

    Also Arm Compiler 6 is based off Clang, and clang defines the GCC flag. See:

     

    c - How to #ifdef by CompilerType ? GCC or VC++ - Stack Overflow

  • Helpful stuff, thanks. That's better than my solution (the github link).

    GB