# Macro unrecognized when compiling assembly code

**URL:** <https://discourse.cmake.org/t/macro-unrecognized-when-compiling-assembly-code/472>\
**Category:** Code\
**Tags:** os:windows\
**Created:** [January 9, 2020, 1:41pm UTC](https://discourse.cmake.org/t/macro-unrecognized-when-compiling-assembly-code/472 "2020-01-09T13:41:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![skulkarni](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@skulkarni](https://discourse.cmake.org/u/skulkarni)\
**Post date:** [January 9, 2020, 1:41pm UTC](https://discourse.cmake.org/t/macro-unrecognized-when-compiling-assembly-code/472/1 "2020-01-09T13:41:52Z")

</div>

Hi,  
When compiling assembly code the macro is not recognized and throwing up error.  
[85%] Building ASM object BLE/nRF52/modules/CMakeFiles/MODULES.dir/nrfx/mdk/gcc\_startup\_nrf52.S.obj  
D:XXXX\gcc\_7\_2\_1\tools\bin\arm-none-eabi-as.exe: unrecognized option `- **BOARD\_PCA10040** ’  
make[2]: \*\*\* [BLE/nRF52/modules/CMakeFiles/MODULES.dir/nrfx/mdk/gcc\_startup\_nrf52.S.obj] Error 1

Here BOARD\_PCA10040 is project macro which is given to assembly code like any other C file.  
Macros are added using **add\_definitions** () method.

Can someone help me where to look into fix the error.

---

<div class="post-metadata">

**Author:** ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)\
**Post date:** [January 9, 2020, 2:08pm UTC](https://discourse.cmake.org/t/macro-unrecognized-when-compiling-assembly-code/472/2 "2020-01-09T14:08:37Z")

</div>

Please post the `add_definitions()` call that is adding the flag.

---

<div class="post-metadata">

**Author:** ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)\
**Post date:** [January 9, 2020, 10:33pm UTC](https://discourse.cmake.org/t/macro-unrecognized-when-compiling-assembly-code/472/3 "2020-01-09T22:33:22Z")

</div>

To avoid unexpected interpretation, it is strongly recommended to use `add_compile_definitions` rather than `add_definitions`.

---

<div class="post-metadata">

**Author:** ![skulkarni](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@skulkarni](https://discourse.cmake.org/u/skulkarni)\
**Post date:** [January 10, 2020, 11:20am UTC](https://discourse.cmake.org/t/macro-unrecognized-when-compiling-assembly-code/472/4 "2020-01-10T11:20:47Z")

</div>

> [@marc.chevrier](#):
>
> add\_definitions

Hi,  
I think **add\_compile\_definitions** is supported in latest version.  
We are using 2.8.12 version in our project. The Cmake is picked from the configuration file which I am not able to edit.

I have installed the latest version 3.16 and I have generated the build file for the same  
add\_compile\_definitions(BOARD\_PCA10040)  
add\_compile\_definitions(CONFIG\_GPIO\_AS\_PINRESET)  
add\_compile\_definitions(FLOAT\_ABI\_HARD)  
add\_compile\_definitions(INITIALIZE\_USER\_SECTIONS)  
add\_compile\_definitions(NO\_VTOR\_CONFIG)

When I looked into flags.make file I still see these definitions as below  
ASM\_DEFINES = -DBOARD\_PCA10040 -DCONFIG\_GPIO\_AS\_PINRESET -DFLOAT\_ABI\_HARD

One thing I have observed  
When I compile with Cmake version 3.16 and “MinGW Makefiles” generator  
assembly code gets compiled without any issues (even when using **add\_definitions** ())

But when I compile with 2.8 version cmake and “Eclipse CDT4 - Unix Makefiles” generator assembly code doesn’t get compiled.

I am not sure whether this issue is related to Generator!

---

<div class="post-metadata">

**Author:** ![skulkarni](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@skulkarni](https://discourse.cmake.org/u/skulkarni)\
**Post date:** [January 10, 2020, 11:27am UTC](https://discourse.cmake.org/t/macro-unrecognized-when-compiling-assembly-code/472/5 "2020-01-10T11:27:15Z")

</div>

add\_definitions(-DBOARD\_PCA10040)  
add\_definitions(-DCONFIG\_GPIO\_AS\_PINRESET)

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [June 4, 2020, 12:54pm UTC](https://discourse.cmake.org/t/macro-unrecognized-when-compiling-assembly-code/472/6 "2020-06-04T12:54:49Z")

</div>

There was a recent issue fixed with GNU’s assembler where its compile definition flag was incorrect. It will be fixed in 3.18. [https://gitlab.kitware.com/cmake/cmake/-/merge\_requests/4838](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4838)
