CLion, CMSIS and error: "expected identifier or '(' before '__asm'"

Hi all

I'm trying to setup a CLion C working environment for my Cortex-M0 embedded processor. I'm completely new to CLion and cmake and I have been struggling for days with this problem:

The issue arise in the core_cm0.h header file included in CMSIS. More specifically at these lines:

#if   defined ( __CC_ARM )
#define __ASM __asm /*!< asm keyword for ARM Compiler */
#define __INLINE __inline /*!< inline keyword for ARM Compiler */
#define __STATIC_INLINE static __inline

My project is as small as it gets with just a main() routine with a while(true) loop. When I try to build I get the error "expected identifier or '(' before '__asm'". I also get a bunch of similar notes and warnings like e.g. "warning: implicit declaration of function '__nop'". What is confusing me the most is that the same project compiles fine in Keil (the IDE I usually work in). So I figure it might be some compiler specific thing. Some flags that I have forgot to set or something? 

This is my CMakeLists.txt :

cmake_minimum_required(VERSION 3.6)
project(Test3 C ASM)


INCLUDE(CMakeForceCompiler)
SET(CMAKE_SYSTEM_NAME Generic)
CMAKE_FORCE_C_COMPILER("C:/Program Files (x86)/GNU Tools ARM Embedded/5.4 2016q2/bin/arm-none-eabi-gcc.exe" GNU)


add_definitions(-DNRF51
-DBOARD_PCA10028
-D__CC_ARM)


set(SOURCE_FILES main.c)


include_directories(../../../components/drivers_nrf/hal)
include_directories(../../../components/device)
include_directories(../../../components/toolchain/CMSIS/Include)
include_directories(../../../components/toolchain)


add_executable(Test3 ${SOURCE_FILES})


SET(DEFINES_IN_FLAGS -DNRF51 -DBOARD_PCA10028 -DBSP_DEFINES_ONLY)
SET(COMMON_FLAGS "-mcpu=cortex-m0 -mthumb -mabi=aapcs --std=gnu99 -Werror -O0 -g3 -mfloat-abi=soft -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums ")
SET(CMAKE_C_FLAGS "${COMMON_FLAGS} ${CMAKE_C_FLAGS}")
SET(CMAKE_ASM_FLAGS "${COMMON_FLAGS} ${CMAKE_C_FLAGS} -x assembler-with-cpp")
SET(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/default_linker_nrf51.ld)
SET(CMAKE_EXE_LINKER_FLAGS "-mcpu=cortex-m0 -Wl,-gc-sections -T --specs=nano.specs -lc -lnosys -mthumb -mabi=aapcs -L ${LINKER_SCRIPT} -Xlinker -Map=${LISTING_DIRECTORY}/${OUTPUT_FILENAME}.map")

Does anybody know what I'm doing wrong? Any help would be much appreciated

-Martin

0
1 comment

I got the answer here. http://stackoverflow.com/questions/39295218/clion-cmsis-and-error-expected-identifier-or-before-asm 

Of some reason that I don't remember I once thought it was wise to define __CC_ARM (a compiler I don't use) in my list file. 

0

Please sign in to leave a comment.