nrf connect sdk 2.1.2 build failing for default sample applications

i just started using nrf connect SDK and tried building a sample IMU example on a ubuntu 22 using the latest sdk and visual studio code. but the build is failing with the following errors.

FAILED: CMakeFiles/app.dir/src/main.c.obj
C:\Projects\ncs\toolchains\v2.1.2\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DKERNEL -DNRF52832_XXAA -DUSE_PARTITION_MANAGER=0 -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -IC:/Projects/ncs/v2.1.2/zephyr/include/zephyr -IC:/Projects/ncs/v2.1.2/zephyr/include -Izephyr/include/generated -IC:/Projects/ncs/v2.1.2/zephyr/soc/arm/nordic_nrf/nrf52 -IC:/Projects/ncs/v2.1.2/zephyr/soc/arm/nordic_nrf/common/. -IC:/Projects/ncs/v2.1.2/nrf/include -IC:/Projects/ncs/v2.1.2/modules/hal/cmsis/CMSIS/Core/Include -IC:/Projects/ncs/v2.1.2/modules/hal/nordic/nrfx -IC:/Projects/ncs/v2.1.2/modules/hal/nordic/nrfx/drivers/include -IC:/Projects/ncs/v2.1.2/modules/hal/nordic/nrfx/mdk -IC:/Projects/ncs/v2.1.2/zephyr/modules/hal_nordic/nrfx/. -IC:/Projects/ncs/v2.1.2/modules/debug/segger/SEGGER -IC:/Projects/ncs/v2.1.2/modules/debug/segger/Config -IC:/Projects/ncs/v2.1.2/zephyr/modules/segger/. -isystem C:/Projects/ncs/v2.1.2/zephyr/lib/libc/minimal/include -isystem c:/projects/ncs/toolchains/v2.1.2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/include -isystem c:/projects/ncs/toolchains/v2.1.2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/include-fixed -Os -imacros C:/Projects/contractual/headx/lsm6dso/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=C:/Projects/ncs/toolchains/v2.1.2/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/Projects/ncs/v2.1.2/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=C:/Projects/contractual/headx/lsm6dso=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/Projects/ncs/v2.1.2/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/Projects/ncs/v2.1.2=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/src/main.c.obj -MF CMakeFiles\app.dir\src\main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj -c ../src/main.c
In file included from C:/Projects/ncs/v2.1.2/zephyr/include/zephyr/sys/util_macro.h:34,
                 from C:/Projects/ncs/v2.1.2/zephyr/include/zephyr/sys/atomic.h:16,
                 from C:/Projects/ncs/v2.1.2/zephyr/include/zephyr/kernel_includes.h:21,
                 from C:/Projects/ncs/v2.1.2/zephyr/include/zephyr/kernel.h:17,
                 from C:/Projects/ncs/v2.1.2/zephyr/include/zephyr/zephyr.h:18,
                 from ../src/main.c:8:
../src/main.c: In function 'main':
C:/Projects/ncs/v2.1.2/zephyr/include/zephyr/sys/util.h:78:55: error: size of unnamed array is negative
   78 | #define ZERO_OR_COMPILE_ERROR(cond) ((int) sizeof(char[1 - 2 * !(cond)]) - 1)
      |                                                       ^
C:/Projects/ncs/v2.1.2/zephyr/include/zephyr/sys/util_internal.h:67:26: note: in definition of macro '__DEBRACKET'
   67 | #define __DEBRACKET(...) __VA_ARGS__
      |                          ^~~~~~~~~~~
C:/Projects/ncs/v2.1.2/zephyr/include/zephyr/sys/util_internal.h:59:2: note: in expansion of macro '__GET_ARG2_DEBRACKET'
   59 |  __GET_ARG2_DEBRACKET(one_or_two_args _if_code, _else_code)
      |  ^~~~~~~~~~~~~~~~~~~~
C:/Projects/ncs/v2.1.2/zephyr/include/zephyr/sys/util_internal.h:54:2: note: in expansion of macro '__COND_CODE'
   54 |  __COND_CODE(_XXXX##_flag, _if_1_code, _else_code)
      |  ^~~~~~~~~~~
C:/Projects/ncs/v2.1.2/zephyr/include/zephyr/sys/util_macro.h:157:2: note: in expansion of macro 'Z_COND_CODE_1'
  157 |  Z_COND_CODE_1(_flag, _if_1_code, _else_code)
      |  ^~~~~~~~~~~~~
C:/Projects/ncs/v2.1.2/zephyr/include/zephyr/device.h:353:2: note: in expansion of macro 'COND_CODE_1'
  353 |  COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(compat),       \
      |  ^~~~~~~~~~~
C:/Projects/ncs/v2.1.2/zephyr/include/zephyr/device.h:355:8: note: in expansion of macro 'ZERO_OR_COMPILE_ERROR'
  355 |       (ZERO_OR_COMPILE_ERROR(0)))
      |        ^~~~~~~~~~~~~~~~~~~~~
../src/main.c:110:29: note: in expansion of macro 'DEVICE_DT_GET_ONE'
  110 |  const struct device *dev = DEVICE_DT_GET_ONE(st_lsm6dso);
      |                             ^~~~~~~~~~~~~~~~~
[72/176] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_packaged.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'C:\Projects\ncs\toolchains\v2.1.2\opt\bin\cmake.EXE' --build 'C:\Projects\contractual\headx\lsm6dso\build'

at first i thought there are some issue with my build environment so i tried installing the sdk on my windows system (with a clean environment) and get the same error. 

Related