CLion, CMSIS and error: "expected identifier or '(' before '__asm'"
<p>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:</p>

<p>The issue arises in the core_cm0.h header file included in CMSIS. More specifically at these lines:</p>

<pre><code>#if   defined ( __CC_ARM )
  #define __ASM            __asm                                      /*!&lt; asm keyword for ARM Compiler */
  #define __INLINE         __inline                                   /*!&lt; inline keyword for ARM Compiler */
  #define __STATIC_INLINE  static __inline
</code></pre>

<p>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. Or is it something special with how the GNU toolchain handles inline assembly?</p>

<p>This is my CMakeLists.txt :</p>

<pre><code>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")
</code></pre>

<p>And this is my toolchain setup in CLion:
<a href="http://i.stack.imgur.com/vs0Rj.png" rel="nofollow">Toolchain</a></p>