I have the source code of an application written in C++ and I just want to comment something using:
#ifdef 0
...
#endif
And I get this error
error: macro names must be identifiers
Why is this happening?
asked Jan 9, 2009 at 1:27
3
The #ifdef directive is used to check if a preprocessor symbol is defined. The standard (C11 6.4.2 Identifiers
) mandates that identifiers must not start with a digit:
identifier:
identifier-nondigit
identifier identifier-nondigit
identifier digit
identifier-nondigit:
nondigit
universal-character-name
other implementation-defined characters>
nondigit: one of
_ a b c d e f g h i j k l m
n o p q r s t u v w x y z
A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z
digit: one of
0 1 2 3 4 5 6 7 8 9
The correct form for using the pre-processor to block out code is:
#if 0
: : :
#endif
You can also use:
#ifdef NO_CHANCE_THAT_THIS_SYMBOL_WILL_EVER_EXIST
: : :
#endif
but you need to be confident that the symbols will not be inadvertently set by code other than your own. In other words, don’t use something like NOTUSED
or DONOTCOMPILE
which others may also use. To be safe, the #if
option should be preferred.
answered Jan 9, 2009 at 1:38
paxdiablopaxdiablo
848k233 gold badges1569 silver badges1944 bronze badges
3
Use the following to evaluate an expression (constant 0 evaluates to false).
#if 0
...
#endif
answered Jan 9, 2009 at 1:33
tvanfossontvanfosson
523k99 gold badges697 silver badges794 bronze badges
This error can also occur if you are not following the marco rules
Like
#define 1K 1024 // Macro rules must be identifiers error occurs
Reason: Macro Should begin with a letter, not a number
Change to
#define ONE_KILOBYTE 1024 // This resolves
James Webster
31.9k11 gold badges69 silver badges114 bronze badges
answered Nov 9, 2011 at 5:37
AnotherDeveloperAnotherDeveloper
2,1312 gold badges23 silver badges27 bronze badges
#ifdef 0
...
#endif
#ifdef expect a macro rather than expression
when using constant or expression
#if 0
...
#endif
or
#if !defined(PP_CHECK) || defined(PP_CHECK_OTHER)
..
#endif
if #ifdef is used the it reports this error
#ifdef !defined(PP_CHECK) || defined(PP_CHECK_OTHER)
..
#endif
Where #ifdef expect a macro rather than macro expresssion
Horizon_Net
5,9594 gold badges31 silver badges34 bronze badges
answered May 28, 2014 at 13:28
Note that you can also hit this error if you accidentally type:
#define <stdio.h>
…instead of…
#include <stdio.>
answered Feb 2, 2013 at 23:00
Drew NoakesDrew Noakes
298k163 gold badges677 silver badges739 bronze badges
Loading
Configuration
Operating system:
Manjaro Linux x86_64
5.14.21-2-MANJARO
PlatformIO Version (platformio --version
):
PlatformIO Core, version 5.3.0b5
IDE:
CLion 2021.3.4
Description of problem
- Can’t Re-Init Project & Include files like
Arduino.h
not found.
Steps to Reproduce
- Follow Instruction on docs.platformio to setup CLion with PlatformIO.
- Open CLion + create new project for
portenta_h7_m7
- Manually configure project profiles in CLion. Toolchains:
Default
; CMake:portenta_h7_m7
- Setup Project config, like mentioned in docs. (Add Debug & Upload)
- Re-init project
- -> ERORR
Actual Results
/home/benjo/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/213.7172.20/bin/cmake/linux/bin/cmake -DCMAKE_BUILD_TYPE=portenta_h7_m7 -DCMAKE_MAKE_PROGRAM=/home/benjo/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/213.7172.20/bin/ninja/linux/ninja -G Ninja /home/benjo/CLionProjects/newProj -- The C compiler identification is GNU 11.2.0 -- The CXX compiler identification is GNU 11.2.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /sbin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /sbin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /home/benjo/CLionProjects/newProj/cmake-build-portenta_h7_m7 Cannot get compiler information: Compiler exited with error code 1: /home/benjo/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -xc++ -DARDUINO=10810 -DARDUINO_ARCH_MBED -DARDUINO_PORTENTA_H7_M7 -DARM_MATH_CM7 -DBT_UART_NO_3M_SUPPORT -DCM4_BOOT_BY_APPLICATION -DCOMPONENT_4343W_FS=1 -DCOMPONENT_CYW43XXX=1 -DCOMPONENT_FLASHIAP=1 -DCOMPONENT_QSPIF=1 -DCOMPONENT_WHD=1 -DCORE_CM7 -DCORE_MAJOR=3 -DCORE_MINOR=0 -DCORE_PATCH=1 -DCYW43XXX_UNBUFFERED_UART -DDEVICE_ANALOGIN=1 -DDEVICE_ANALOGOUT=1 -DDEVICE_CAN=1 -DDEVICE_CRC=1 -DDEVICE_EMAC=1 -DDEVICE_FLASH=1 -DDEVICE_I2C=1 -DDEVICE_I2CSLAVE=1 -DDEVICE_I2C_ASYNCH=1 -DDEVICE_INTERRUPTIN=1 -DDEVICE_LPTICKER=1 -DDEVICE_MPU=1 -DDEVICE_PORTIN=1 -DDEVICE_PORTINOUT=1 -DDEVICE_PORTOUT=1 -DDEVICE_PWMOUT=1 -DDEVICE_QSPI=1 -DDEVICE_RESET_REASON=1 -DDEVICE_RTC=1 -DDEVICE_SERIAL=1 -DDEVICE_SERIAL_FC=1 -DDEVICE_SLEEP=1 -DDEVICE_SPI=1 -DDEVICE_SPISLAVE=1 -DDEVICE_SPI_ASYNCH=1 -DDEVICE_STDIO_MESSAGES=1 -DDEVICE_TRNG=1 -DDEVICE_USBDEVICE=1 -DDEVICE_USTICKER=1 -DDEVICE_WATCHDOG=1 -DEXTRA_IDLE_STACK_REQUIRED -DFEATURE_BLE=1 -DMBEDTLS_FS_IO -DMBEDTLS_SHA1_C -DMBED_BUILD_TIMESTAMP=1648633310.1874359 -DMBED_NO_GLOBAL_USING_DIRECTIVE=1 -DMBED_TICKLESS -DMETAL_INTERNAL -DMETAL_MAX_DEVICE_REGIONS=2 -DNO_ATOMIC_64_SUPPORT -DPLATFORMIO=50300 -DQSPI_NO_SAMPLE_SHIFT -DRPMSG_BUFFER_SIZE=100 -DSTM32H747xx -DTARGET_CORDIO -DTARGET_CORTEX -DTARGET_CORTEX_M -DTARGET_LIKE_CORTEX_M7 -DTARGET_LIKE_MBED -DTARGET_M7 -DTARGET_MCU_STM32 -DTARGET_MCU_STM32H7 -DTARGET_MCU_STM32H747xI -DTARGET_NAME=PORTENTA_H7_M7 -DTARGET_PORTENTA_H7 -DTARGET_PORTENTA_H7_M7 -DTARGET_RELEASE -DTARGET_RTOS_M4_M7 -DTARGET_STM -DTARGET_STM32H7 -DTARGET_STM32H747xI -DTARGET_STM32H747xI_CM7 -DTOOLCHAIN_GCC -DTOOLCHAIN_GCC_ARM -DTRANSACTION_QUEUE_SIZE_SPI=2 -DUSB_DYNAMIC_CONFIGURATION -DUSE_ARDUINO_PINOUT -DUSE_FULL_LL_DRIVER -DUSE_HAL_DRIVER -DVIRTIO_MASTER_ONLY -D__CMSIS_RTOS -D__CORTEX_M7 -D__FPU_PRESENT=1 -D__MBED_CMSIS_RTOS_CM -D__MBED__=1 -Wvla -fno-rtti -std=gnu++14 -DAPPLICATION_ADDR=0x8040000 -DAPPLICATION_RAM_ADDR=0x24000000 -DAPPLICATION_RAM_SIZE=0x80000 -DAPPLICATION_SIZE=0xc0000 -DMBED_RAM1_SIZE=0x80000 -DMBED_RAM1_START=0x24000000 -DMBED_RAM_SIZE=0x80000 -DMBED_RAM_START=0x24000000 -DMBED_ROM_SIZE=0x100000 -DMBED_ROM_START=0x8000000 -DMBED_TRAP_ERRORS_ENABLED=1 -Os -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -c -fdata-sections -ffunction-sections -fmessage-length=0 -fomit-frame-pointer -funsigned-char -mcpu=cortex-m7 -mfloat-abi=softfp -mfpu=fpv5-d16 -mthumb -iprefix/home/benjo/.platformio/packages/framework-arduino-mbed/cores/arduino -iwithprefixbefore/mbed -iwithprefixbefore/mbed/cmsis -iwithprefixbefore/mbed/cmsis/CMSIS_5 - ... iwithprefixbefore/mbed/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_STM32H747xI_CM7 -nostdlib -D-DCM4_BINARY_START=0x08100000 -std=gnu++14 -fpch-preprocess -v -dD -E Using built-in specs. COLLECT_GCC=/home/benjo/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ Target: arm-none-eabi Configured with: /tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/src/gcc/configure --target=arm-none-eabi --prefix=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/install-native --libexecdir=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/install-native/lib --infodir=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/install-native/share/doc/gcc-arm-none-eabi/info --mandir=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/install-native/share/doc/gcc-arm-none-eabi/man --htmldir=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/install-native/share/doc/gcc-arm-none-eabi/html --pdfdir=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/install-native/share/doc/gcc-arm-none-eabi/pdf --enable-languages=c,c++ --enable-plugins --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/install-native/arm-none-eabi --build=x86_64-linux-gnu --host=x86_64-linux-gnu --with-gmp=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/build-native/host-libs/usr --with-mpfr=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/build-native/host-libs/usr --with-mpc=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/build-native/host-libs/usr --with-isl=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/build-native/host-libs/usr --with-libelf=/tmp/jenkins/jenkins-GCC-7-build_toolchain_docker-633_20171130_1512067137/build-native/host-libs/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU Tools for Arm Embedded Processors 7-2017-q4-major' --with-multilib-list=rmprofile Thread model: single gcc version 7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204] (GNU Tools for Arm Embedded Processors 7-2017-q4-major) COLLECT_GCC_OPTIONS='-D' 'ARDUINO=10810' '-D' 'ARDUINO_ARCH_MBED' '-D' 'ARDUINO_PORTENTA_H7_M7' '-D' 'ARM_MATH_CM7' '-D' 'BT_UART_NO_3M_SUPPORT' '-D' 'CM4_BOOT_BY_APPLICATION' '-D' 'COMPONENT_4343W_FS=1' '-D' 'COMPONENT_CYW43XXX=1' '-D' 'COMPONENT_FLASHIAP=1' '-D' 'COMPONENT_QSPIF=1' '-D' 'COMPONENT_WHD=1' '-D' 'CORE_CM7' '-D' 'CORE_MAJOR=3' '-D' 'CORE_MINOR=0' '-D' 'CORE_PATCH=1' '-D' 'CYW43XXX_UNBUFFERED_UART' '-D' 'DEVICE_ANALOGIN=1' '-D' 'DEVICE_ANALOGOUT=1' '-D' 'DEVICE_CAN=1' '-D' 'DEVICE_CRC=1' '-D' 'DEVICE_EMAC=1' '-D' 'DEVICE_FLASH=1' '-D' 'DEVICE_I2C=1' '-D' 'DEVICE_I2CSLAVE=1' '-D' 'DEVICE_I2C_ASYNCH=1' '-D' 'DEVICE_INTERRUPTIN=1' '-D' 'DEVICE_LPTICKER=1' '-D' 'DEVICE_MPU=1' '-D' 'DEVICE_PORTIN=1' '-D' 'DEVICE_PORTINOUT=1' '-D' 'DEVICE_PORTOUT=1' '-D' 'DEVICE_PWMOUT=1' '-D' 'DEVICE_QSPI=1' '-D' 'DEVICE_RESET_REASON=1' '-D' 'DEVICE_RTC=1' '-D' 'DEVICE_SERIAL=1' '-D' 'DEVICE_SERIAL_FC=1' '-D' 'DEVICE_SLEEP=1' '-D' 'DEVICE_SPI=1' '-D' 'DEVICE_SPISLAVE=1' '-D' 'DEVICE_SPI_ASYNCH=1' '-D' 'DEVICE_STDIO_MESSAGES=1' '-D' 'DEVICE_TRNG=1' '-D' 'DEVICE_USBDEVICE=1' '-D' 'DEVICE_USTICKER=1' '-D' 'DEVICE_WATCHDOG=1' '-D' 'EXTRA_IDLE_STACK_REQUIRED' '-D' 'FEATURE_BLE=1' '-D' 'MBEDTLS_FS_IO' '-D' 'MBEDTLS_SHA1_C' '-D' 'MBED_BUILD_TIMESTAMP=1648633310.1874359' '-D' 'MBED_NO_GLOBAL_USING_DIRECTIVE=1' '-D' 'MBED_TICKLESS' '-D' 'METAL_INTERNAL' '-D' 'METAL_MAX_DEVICE_REGIONS=2' '-D' 'NO_ATOMIC_64_SUPPORT' '-D' 'PLATFORMIO=50300' '-D' 'QSPI_NO_SAMPLE_SHIFT' '-D' 'RPMSG_BUFFER_SIZE=100' '-D' 'STM32H747xx' '-D' 'TARGET_CORDIO' '-D' 'TARGET_CORTEX' '-D' 'TARGET_CORTEX_M' '-D' 'TARGET_LIKE_CORTEX_M7' '-D' 'TARGET_LIKE_MBED' '-D' 'TARGET_M7' '-D' 'TARGET_MCU_STM32' '-D' 'TARGET_MCU_STM32H7' '-D' 'TARGET_MCU_STM32H747xI' '-D' 'TARGET_NAME=PORTENTA_H7_M7' '-D' 'TARGET_PORTENTA_H7' '-D' 'TARGET_PORTENTA_H7_M7' '-D' 'TARGET_RELEASE' '-D' 'TARGET_RTOS_M4_M7' '-D' 'TARGET_STM' '-D' 'TARGET_STM32H7' '-D' 'TARGET_STM32H747xI' '-D' 'TARGET_STM32H747xI_CM7' '-D' 'TOOLCHAIN_GCC' '-D' 'TOOLCHAIN_GCC_ARM' '-D' 'TRANSACTION_QUEUE_SIZE_SPI=2' '-D' 'USB_DYNAMIC_CONFIGURATION' '-D' 'USE_ARDUINO_PINOUT' '-D' 'USE_FULL_LL_DRIVER' '-D' 'USE_HAL_DRIVER' '-D' 'VIRTIO_MASTER_ONLY' '-D' '__CMSIS_RTOS' '-D' '__CORTEX_M7' '-D' '__FPU_PRESENT=1' '-D' '__MBED_CMSIS_RTOS_CM' '-D' '__MBED__=1' '-Wvla' '-fno-rtti' '-std=gnu++14' '-D' 'APPLICATION_ADDR=0x8040000' '-D' 'APPLICATION_RAM_ADDR=0x24000000' '-D' 'APPLICATION_RAM_SIZE=0x80000' '-D' 'APPLICATION_SIZE=0xc0000' '-D' 'MBED_RAM1_SIZE=0x80000' '-D' 'MBED_RAM1_START=0x24000000' '-D' 'MBED_RAM_SIZE=0x80000' '-D' 'MBED_RAM_START=0x24000000' '-D' 'MBED_ROM_SIZE=0x100000' '-D' 'MBED_ROM_START=0x8000000' '-D' 'MBED_TRAP_ERRORS_ENABLED=1' '-Os' '-Wall' '-Wextra' '-Wno-missing-field-initializers' '-Wno-unused-parameter' '-c' '-fdata-sections' '-ffunction-sections' '-fmessage-length=0' '-fomit-frame-pointer' '-funsigned-char' '-mcpu=cortex-m7' '-mfloat-abi=softfp' '-mfpu=fpv5-d16' '-mthumb' '-iprefix' '/home/benjo/.platformio/packages/framework-arduino-mbed/cores/arduino' '-iwithprefixbefore' '/mbed' '-iwithprefixbefore' '/mbed/cmsis' '-iwithprefixbefore' '/mbed/cmsis/CMSIS_5' '-iwithprefixbefore' '/mbed/cmsis/CMSIS_5/CMSIS' '-iwithprefixbefore' '/mbed/cmsis/CMSIS_5/CMSIS/RTOS2' '-iwithprefixbefore' '/mbed/cmsis/CMSIS_5/CMSIS/RTOS2/Include' '-iwithprefixbefore' '/mbed/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/COMPONENT_WHD/interface' '-iwithprefixbefore' ... '/mbed/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_STM32H747xI_CM7' '-nostdlib' '-D' '-DCM4_BINARY_START=0x08100000' '-std=gnu++14' '-fpch-preprocess' '-v' '-dD' '-E' '-D' '___CIDR_DEFINITIONS_END' /home/benjo/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/7.2.1/cc1plus -E -quiet -v -imultilib thumb/v7e-m/fpv5/softfp -iprefix /home/benjo/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/7.2.1/ -isysroot /home/benjo/.platformio/packages/toolchain-gccarmnoneeabi/bin/../arm-none-eabi -D__USES_INITFINI__ -D ARDUINO=10810 -D ARDUINO_ARCH_MBED -D ARDUINO_PORTENTA_H7_M7 -D ARM_MATH_CM7 -D BT_UART_NO_3M_SUPPORT -D CM4_BOOT_BY_APPLICATION -D COMPONENT_4343W_FS=1 -D COMPONENT_CYW43XXX=1 -D COMPONENT_FLASHIAP=1 -D COMPONENT_QSPIF=1 -D COMPONENT_WHD=1 -D CORE_CM7 -D CORE_MAJOR=3 -D CORE_MINOR=0 -D CORE_PATCH=1 -D CYW43XXX_UNBUFFERED_UART -D DEVICE_ANALOGIN=1 -D DEVICE_ANALOGOUT=1 -D DEVICE_CAN=1 -D DEVICE_CRC=1 -D DEVICE_EMAC=1 -D DEVICE_FLASH=1 -D DEVICE_I2C=1 -D DEVICE_I2CSLAVE=1 -D DEVICE_I2C_ASYNCH=1 -D DEVICE_INTERRUPTIN=1 -D DEVICE_LPTICKER=1 -D DEVICE_MPU=1 -D DEVICE_PORTIN=1 -D DEVICE_PORTINOUT=1 -D DEVICE_PORTOUT=1 -D DEVICE_PWMOUT=1 -D DEVICE_QSPI=1 -D DEVICE_RESET_REASON=1 -D DEVICE_RTC=1 -D DEVICE_SERIAL=1 -D DEVICE_SERIAL_FC=1 -D DEVICE_SLEEP=1 -D DEVICE_SPI=1 -D DEVICE_SPISLAVE=1 -D DEVICE_SPI_ASYNCH=1 -D DEVICE_STDIO_MESSAGES=1 -D DEVICE_TRNG=1 -D DEVICE_USBDEVICE=1 -D DEVICE_USTICKER=1 -D DEVICE_WATCHDOG=1 -D EXTRA_IDLE_STACK_REQUIRED -D FEATURE_BLE=1 -D MBEDTLS_FS_IO -D MBEDTLS_SHA1_C -D MBED_BUILD_TIMESTAMP=1648633310.1874359 -D MBED_NO_GLOBAL_USING_DIRECTIVE=1 -D MBED_TICKLESS -D METAL_INTERNAL -D METAL_MAX_DEVICE_REGIONS=2 -D NO_ATOMIC_64_SUPPORT -D PLATFORMIO=50300 -D QSPI_NO_SAMPLE_SHIFT -D RPMSG_BUFFER_SIZE=100 -D STM32H747xx -D TARGET_CORDIO -D TARGET_CORTEX -D TARGET_CORTEX_M -D TARGET_LIKE_CORTEX_M7 -D TARGET_LIKE_MBED -D TARGET_M7 -D TARGET_MCU_STM32 -D TARGET_MCU_STM32H7 -D TARGET_MCU_STM32H747xI -D TARGET_NAME=PORTENTA_H7_M7 -D TARGET_PORTENTA_H7 -D TARGET_PORTENTA_H7_M7 -D TARGET_RELEASE -D TARGET_RTOS_M4_M7 -D TARGET_STM -D TARGET_STM32H7 -D TARGET_STM32H747xI -D TARGET_STM32H747xI_CM7 -D TOOLCHAIN_GCC -D TOOLCHAIN_GCC_ARM -D TRANSACTION_QUEUE_SIZE_SPI=2 -D USB_DYNAMIC_CONFIGURATION -D USE_ARDUINO_PINOUT -D USE_FULL_LL_DRIVER -D USE_HAL_DRIVER -D VIRTIO_MASTER_ONLY -D __CMSIS_RTOS -D __CORTEX_M7 -D __FPU_PRESENT=1 -D __MBED_CMSIS_RTOS_CM -D __MBED__=1 -D APPLICATION_ADDR=0x8040000 -D APPLICATION_RAM_ADDR=0x24000000 -D APPLICATION_RAM_SIZE=0x80000 -D APPLICATION_SIZE=0xc0000 -D MBED_RAM1_SIZE=0x80000 -D MBED_RAM1_START=0x24000000 -D MBED_RAM_SIZE=0x80000 -D MBED_RAM_START=0x24000000 -D MBED_ROM_SIZE=0x100000 -D MBED_ROM_START=0x8000000 -D MBED_TRAP_ERRORS_ENABLED=1 -D -DCM4_BINARY_START=0x08100000 -D ___CIDR_DEFINITIONS_END -iprefix /home/benjo/.platformio/packages/framework-arduino-mbed/cores/arduino -iwithprefixbefore /mbed -iwithprefixbefore /mbed/cmsis -iwithprefixbefore /mbed/cmsis/CMSIS_5 -iwithprefixbefore /mbed/cmsis/CMSIS_5/CMSIS -iwithprefixbefore /mbed/cmsis/CMSIS_5/CMSIS/RTOS2 -iwithprefixbefore /mbed/cmsis/CMSIS_5/CMSIS/RTOS2/Include -iwithprefixbefore ... iwithprefixbefore /mbed/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Source -iwithprefixbefore /mbed/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/COMPONENT_WHD/resources/firmware/COMPONENT_4343W_FS -iwithprefixbefore /mbed/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/COMPONENT_WHD/resources/nvram -iwithprefixbefore /mbed/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_STM32H747xI_CM7 /tmp/compiler-file2493242467203082620 -mcpu=cortex-m7 -mfloat-abi=softfp -mfpu=fpv5-d16 -mthumb -std=gnu++14 -std=gnu++14 -Wvla -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -fno-rtti -fdata-sections -ffunction-sections -fmessage-length=0 -fomit-frame-pointer -funsigned-char -fpch-preprocess -Os -dD ignoring nonexistent directory "/home/benjo/.platformio/packages/framework-arduino-mbed/cores/arduino../../../../arm-none-eabi/include/c++/7.2.1" ignoring nonexistent directory "/home/benjo/.platformio/packages/toolchain-gccarmnoneeabi/bin/../arm-none-eabi/usr/local/include" ignoring nonexistent directory "/home/benjo/.platformio/packages/toolchain-gccarmnoneeabi/bin/../arm-none-eabi/usr/include" #include "..." search starts here: #include <...> search starts here: /home/benjo/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed ... /home/benjo/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/../../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/include End of search list. <command-line>:0:1: error: macro names must be identifiers
Expected Results
- Successfully re-init project and find
Arduino.h
.
If problems with PlatformIO Build System:
The content of platformio.ini
, right after init:
[env:portenta_h7_m7] platform = ststm32 board = portenta_h7_m7 framework = arduino
Source file to reproduce issue, right after init. Arduino.h file not found:
#include <Arduino.h> void setup() { // write your initialization code here } void loop() { // write your code here }
Additional info
- Uploading sketch to the
portenta_h7_m7
by clicking the run button works! - Using PlatformIO in VSCode works fine.
Update
- Tried several other Boards like (Arduino Uno, ESP 8266 and ESP32) which work like a charm Thanks for the good work!
У меня есть исходный код приложения, написанного на С++, и я просто хочу что-то прокомментировать, используя:
#ifdef 0
...
#endif
И я получаю эту ошибку
ошибка: имена макросов должны быть идентификаторами
Почему это происходит?
Ответ 1
Директива #ifdef используется для проверки наличия символа препроцессора. Стандарт (C11 6.4.2 Identifiers
) требует, чтобы идентификаторы не начинались с цифры:
identifier:
identifier-nondigit
identifier identifier-nondigit
identifier digit
identifier-nondigit:
nondigit
universal-character-name
other implementation-defined characters>
nondigit: one of
_ a b c d e f g h i j k l m
n o p q r s t u v w x y z
A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z
digit: one of
0 1 2 3 4 5 6 7 8 9
Правильная форма использования препроцессора для блокировки кода:
#if 0
: : :
#endif
Вы также можете использовать:
#ifdef NO_CHANCE_THAT_THIS_SYMBOL_WILL_EVER_EXIST
: : :
#endif
но вам нужно быть уверенным, что символы не будут непреднамеренно установлены кодом, отличным от вашего. Другими словами, не используйте что-то вроде NOTUSED
или DONOTCOMPILE
, которое другие могут использовать. Чтобы быть в безопасности, предпочтительнее выбрать #if
.
Ответ 2
Используйте следующее, чтобы оценить выражение (константа 0 принимает значение false).
#if 0
...
#endif
Ответ 3
Эта ошибка также может возникать, если вы не выполняете правила marco
Как
#define 1K 1024 // Macro rules must be identifiers error occurs
Причина: макрос Должен начинаться с буквы, а не числа
Изменить на
#define ONE_KILOBYTE 1024 // This resolves
Ответ 4
Обратите внимание, что вы также можете нажать эту ошибку, если случайно введите:
#define <stdio.h>
… вместо…
#include <stdio.>
Ответ 5
#ifdef 0
...
#endif
#ifdef ожидает макрос, а не выражение
при использовании константы или выражения
#if 0
...
#endif
или
#if !defined(PP_CHECK) || defined(PP_CHECK_OTHER)
..
#endif
если используется #ifdef, он сообщает об этой ошибке
#ifdef !defined(PP_CHECK) || defined(PP_CHECK_OTHER)
..
#endif
Где #ifdef ожидает макрос, а не выражение макроса
Ответ 6
Иногда, если вы копируете код из PDF-документа и вставляете его в свой редактор; скрытые странные символы включены. Таким образом, эта ошибка может также возникать в этой ситуации.
Будьте осторожны. Вы должны заменить все пробелы, скопированные для новых, а также сделать то же самое с возвратом каретки.
I have the source code of an application written in C++ and I just want to comment something using:
#ifdef 0
...
#endif
And I get this error
error: macro names must be identifiers
Why is this happening?
asked Jan 9, 2009 at 1:27
3
The #ifdef directive is used to check if a preprocessor symbol is defined. The standard (C11 6.4.2 Identifiers
) mandates that identifiers must not start with a digit:
identifier:
identifier-nondigit
identifier identifier-nondigit
identifier digit
identifier-nondigit:
nondigit
universal-character-name
other implementation-defined characters>
nondigit: one of
_ a b c d e f g h i j k l m
n o p q r s t u v w x y z
A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z
digit: one of
0 1 2 3 4 5 6 7 8 9
The correct form for using the pre-processor to block out code is:
#if 0
: : :
#endif
You can also use:
#ifdef NO_CHANCE_THAT_THIS_SYMBOL_WILL_EVER_EXIST
: : :
#endif
but you need to be confident that the symbols will not be inadvertently set by code other than your own. In other words, don’t use something like NOTUSED
or DONOTCOMPILE
which others may also use. To be safe, the #if
option should be preferred.
answered Jan 9, 2009 at 1:38
paxdiablopaxdiablo
837k230 gold badges1560 silver badges1928 bronze badges
3
Use the following to evaluate an expression (constant 0 evaluates to false).
#if 0
...
#endif
answered Jan 9, 2009 at 1:33
tvanfossontvanfosson
519k97 gold badges697 silver badges794 bronze badges
This error can also occur if you are not following the marco rules
Like
#define 1K 1024 // Macro rules must be identifiers error occurs
Reason: Macro Should begin with a letter, not a number
Change to
#define ONE_KILOBYTE 1024 // This resolves
James Webster
31.7k11 gold badges69 silver badges114 bronze badges
answered Nov 9, 2011 at 5:37
AnotherDeveloperAnotherDeveloper
2,1112 gold badges25 silver badges27 bronze badges
#ifdef 0
...
#endif
#ifdef expect a macro rather than expression
when using constant or expression
#if 0
...
#endif
or
#if !defined(PP_CHECK) || defined(PP_CHECK_OTHER)
..
#endif
if #ifdef is used the it reports this error
#ifdef !defined(PP_CHECK) || defined(PP_CHECK_OTHER)
..
#endif
Where #ifdef expect a macro rather than macro expresssion
Horizon_Net
5,9094 gold badges31 silver badges34 bronze badges
answered May 28, 2014 at 13:28
Note that you can also hit this error if you accidentally type:
#define <stdio.h>
…instead of…
#include <stdio.>
answered Feb 2, 2013 at 23:00
Drew NoakesDrew Noakes
294k162 gold badges669 silver badges736 bronze badges
11223344 0 / 0 / 0 Регистрация: 09.01.2014 Сообщений: 4 |
||||
1 |
||||
09.01.2014, 15:12. Показов 10194. Ответов 6 Метки нет (Все метки)
Не знаю как исправить
Добавлено через 8 минут
__________________ 0 |
alsav22 5493 / 4888 / 831 Регистрация: 04.06.2011 Сообщений: 13,587 |
||||
09.01.2014, 15:21 |
2 |
|||
Если так:
0 |
0 / 0 / 0 Регистрация: 09.01.2014 Сообщений: 4 |
|
09.01.2014, 15:25 [ТС] |
3 |
Тоже ошибка macro names must be identifiers 0 |
5493 / 4888 / 831 Регистрация: 04.06.2011 Сообщений: 13,587 |
|
09.01.2014, 15:33 |
4 |
Тоже ошибка macro names must be identifiers На какой строке? Добавлено через 1 минуту 0 |
0 / 0 / 0 Регистрация: 09.01.2014 Сообщений: 4 |
|
09.01.2014, 15:36 [ТС] |
5 |
На первой строчке в файле 1.h показывает Добавлено через 1 минуту 0 |
alsav22 5493 / 4888 / 831 Регистрация: 04.06.2011 Сообщений: 13,587 |
||||
09.01.2014, 15:37 |
6 |
|||
Цифру перед макросом уберите:
1 |
0 / 0 / 0 Регистрация: 09.01.2014 Сообщений: 4 |
|
09.01.2014, 15:43 [ТС] |
7 |
Спасибо alsav22. Теперь уже лучше и нет ошибок 0 |
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Closed
duanyongli opened this issue
Aug 19, 2020
· 8 comments
· Fixed by #54
Comments
platform: Jetson Xavier NX, ubuntu18.04
It seems like #9. But #9 had been resolved.
Can you copy and paste the full verbose output from catkin build
? Offhand I believe the command for this is catkin build --verbose
.
Some more info about the build environment will be helpful:
- What version of PCL is installed?
- What version of CUDA are you using?
Thanks for your reply.
More info about the build environment:
- What version of PCL is installed? PCL1.8
- What version of CUDA are you using? cuda 10.2
verbose output follows:
[ 63%] Building CXX object CMakeFiles/yak_frontend.dir/src/yak_server.cpp.o
[ 68%] Building CXX object CMakeFiles/yak_frontend.dir/src/kfusion/tsdf_container.cpp.o
/usr/bin/c++ -D-ffloat-store -DDISABLE_DAVIDSDK -DDISABLE_DSSDK -DDISABLE_ENSENSO -DDISABLE_LIBUSB_1_0 -DDISABLE_PCAP -DDISABLE_PNG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DvtkFiltersFlowPaths_AUTOINIT=»1(vtkFiltersParallelFlowPaths)» -DvtkIOExodus_AUTOINIT=»1(vtkIOParallelExodus)» -DvtkIOGeometry_AUTOINIT=»1(vtkIOMPIParallel)» -DvtkIOImage_AUTOINIT=»1(vtkIOMPIImage)» -DvtkIOParallel_AUTOINIT=»1(vtkIOMPIParallel)» -DvtkIOSQL_AUTOINIT=»2(vtkIOMySQL,vtkIOPostgreSQL)» -DvtkRenderingContext2D_AUTOINIT=»1(vtkRenderingContextOpenGL)» -DvtkRenderingCore_AUTOINIT=»3(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingOpenGL)» -DvtkRenderingFreeType_AUTOINIT=»2(vtkRenderingFreeTypeFontConfig,vtkRenderingMatplotlib)» -DvtkRenderingLIC_AUTOINIT=»1(vtkRenderingParallelLIC)» -DvtkRenderingVolume_AUTOINIT=»1(vtkRenderingVolumeOpenGL)» -Dyak_frontend_EXPORTS -isystem /usr/include/vtk-6.3 -isystem /usr/include/freetype2 -isystem /usr/lib/aarch64-linux-gnu/openmpi/include/openmpi -isystem /usr/lib/aarch64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent -isystem /usr/lib/aarch64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent/include -isystem /usr/lib/aarch64-linux-gnu/openmpi/include -isystem /usr/include/python2.7 -isystem /usr/include/aarch64-linux-gnu -isystem /usr/include/hdf5/openmpi -isystem /usr/include/libxml2 -isystem /usr/include/jsoncpp -isystem /usr/include/tcl -I/usr/local/cuda/include -I/home/research/catkin_ws_test/src/yak/yak/include -isystem /usr/include/pcl-1.8 -isystem /usr/include/eigen3 -isystem /usr/include/ni -isystem /usr/include/openni2 -isystem /usr/include/opencv -isystem /usr/include/aarch64-linux-gnu/qt5 -isystem /usr/include/aarch64-linux-gnu/qt5/QtWidgets -isystem /usr/include/aarch64-linux-gnu/qt5/QtGui -isystem /usr/include/aarch64-linux-gnu/qt5/QtCore -isystem /usr/lib/aarch64-linux-gnu/qt5/mkspecs/linux-g++ -fPIC -fPIC -std=gnu++14 -o CMakeFiles/yak_frontend.dir/src/yak_server.cpp.o -c /home/research/catkin_ws_test/src/yak/yak/src/yak_server.cpp
/usr/bin/c++ -D-ffloat-store -DDISABLE_DAVIDSDK -DDISABLE_DSSDK -DDISABLE_ENSENSO -DDISABLE_LIBUSB_1_0 -DDISABLE_PCAP -DDISABLE_PNG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DvtkFiltersFlowPaths_AUTOINIT=»1(vtkFiltersParallelFlowPaths)» -DvtkIOExodus_AUTOINIT=»1(vtkIOParallelExodus)» -DvtkIOGeometry_AUTOINIT=»1(vtkIOMPIParallel)» -DvtkIOImage_AUTOINIT=»1(vtkIOMPIImage)» -DvtkIOParallel_AUTOINIT=»1(vtkIOMPIParallel)» -DvtkIOSQL_AUTOINIT=»2(vtkIOMySQL,vtkIOPostgreSQL)» -DvtkRenderingContext2D_AUTOINIT=»1(vtkRenderingContextOpenGL)» -DvtkRenderingCore_AUTOINIT=»3(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingOpenGL)» -DvtkRenderingFreeType_AUTOINIT=»2(vtkRenderingFreeTypeFontConfig,vtkRenderingMatplotlib)» -DvtkRenderingLIC_AUTOINIT=»1(vtkRenderingParallelLIC)» -DvtkRenderingVolume_AUTOINIT=»1(vtkRenderingVolumeOpenGL)» -Dyak_frontend_EXPORTS -isystem /usr/include/vtk-6.3 -isystem /usr/include/freetype2 -isystem /usr/lib/aarch64-linux-gnu/openmpi/include/openmpi -isystem /usr/lib/aarch64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent -isystem /usr/lib/aarch64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent/include -isystem /usr/lib/aarch64-linux-gnu/openmpi/include -isystem /usr/include/python2.7 -isystem /usr/include/aarch64-linux-gnu -isystem /usr/include/hdf5/openmpi -isystem /usr/include/libxml2 -isystem /usr/include/jsoncpp -isystem /usr/include/tcl -I/usr/local/cuda/include -I/home/research/catkin_ws_test/src/yak/yak/include -isystem /usr/include/pcl-1.8 -isystem /usr/include/eigen3 -isystem /usr/include/ni -isystem /usr/include/openni2 -isystem /usr/include/opencv -isystem /usr/include/aarch64-linux-gnu/qt5 -isystem /usr/include/aarch64-linux-gnu/qt5/QtWidgets -isystem /usr/include/aarch64-linux-gnu/qt5/QtGui -isystem /usr/include/aarch64-linux-gnu/qt5/QtCore -isystem /usr/lib/aarch64-linux-gnu/qt5/mkspecs/linux-g++ -fPIC -fPIC -std=gnu++14 -o CMakeFiles/yak_frontend.dir/src/kfusion/tsdf_container.cpp.o -c /home/research/catkin_ws_test/src/yak/yak/src/kfusion/tsdf_container.cpp
[ 84%] Built target yak_marching_cubes
/usr/bin/make -f CMakeFiles/marching_cubes_tests.dir/build.make CMakeFiles/marching_cubes_tests.dir/depend
make[2]: Entering directory ‘/home/research/catkin_ws_test/build/yak’
cd /home/research/catkin_ws_test/build/yak && /usr/bin/cmake -E cmake_depends «Unix Makefiles» /home/research/catkin_ws_test/src/yak/yak /home/research/catkin_ws_test/src/yak/yak /home/research/catkin_ws_test/build/yak /home/research/catkin_ws_test/build/yak /home/research/catkin_ws_test/build/yak/CMakeFiles/marching_cubes_tests.dir/DependInfo.cmake —color=
:0:1: error: macro names must be identifiers
:0:1: error: macro names must be identifiers
make[2]: Leaving directory ‘/home/research/catkin_ws_test/build/yak’
/usr/bin/make -f CMakeFiles/marching_cubes_tests.dir/build.make CMakeFiles/marching_cubes_tests.dir/build
make[2]: Entering directory ‘/home/research/catkin_ws_test/build/yak’
make[2]: Nothing to be done for ‘CMakeFiles/marching_cubes_tests.dir/build’.
make[2]: Leaving directory ‘/home/research/catkin_ws_test/build/yak’
[ 94%] Built target marching_cubes_tests
CMakeFiles/yak_frontend.dir/build.make:86: recipe for target ‘CMakeFiles/yak_frontend.dir/src/kfusion/tsdf_container.cpp.o’ failed
make[2]: *** [CMakeFiles/yak_frontend.dir/src/kfusion/tsdf_container.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs….
CMakeFiles/yak_frontend.dir/build.make:62: recipe for target ‘CMakeFiles/yak_frontend.dir/src/yak_server.cpp.o’ failed
make[2]: Leaving directory ‘/home/research/catkin_ws_test/build/yak’
make[2]: *** [CMakeFiles/yak_frontend.dir/src/yak_server.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/yak_frontend.dir/all’ failed
make[1]: Leaving directory ‘/home/research/catkin_ws_test/build/yak’
make[1]: *** [CMakeFiles/yak_frontend.dir/all] Error 2
Makefile:129: recipe for target ‘all’ failed
make: *** [all] Error 2
cd /home/research/catkin_ws_test/build/yak; catkin build —get-env yak | catkin env -si /usr/bin/make —jobserver-fds=6,7 -j; cd —
@duanyongli Could you select the text in your console and paste it as a comment instead of posting it as a screenshot? It’s easier to read that way, and we can search it for keywords too.
In any case, I’m suspicious of that -D-ffloat-store
argument at the beginning of the list of compiler arguments. -ffloat-store
is a predefined GCC flag, and prepending -D
to something tells GCC to treat whatever comes after -D
as a macro name, which isn’t the right thing to do in this case. I think the error you see is because macro names can’t have hyphens in them, so the compiler gives an error when it encounters the invalid name.
I don’t think that this is a problem with the Yak library or its dependencies, since we have CI jobs that build with CUDA 10.2 on Ubuntu 18.04. If you can find what is adding -D-ffloat-store
to the compiler options and figure out how to remove it I think you’ll be able to solve this problem.
In any case, I’m suspicious of that
-D-ffloat-store
argument at the beginning of the list of compiler arguments.-ffloat-store
is a predefined GCC flag, and prepending-D
to something tells GCC to treat whatever comes after-D
as a macro name, which isn’t the right thing to do in this case. I think the error you see is because macro names can’t have hyphens in them, so the compiler gives an error when it encounters the invalid name.I don’t think that this is a problem with the Yak library or its dependencies, since we have CI jobs that build with CUDA 10.2 on Ubuntu 18.04. If you can find what is adding
-D-ffloat-store
to the compiler options and figure out how to remove it I think you’ll be able to solve this problem.
I think -D-ffloat-store comes from PCL.
find_package(PCL 1.8 REQUIRED COMPONENTS common io geometry)
message(WARNING ${PCL_DEFINITIONS})
message says:
CMake Warning at CMakeLists.txt:17 (message):
-ffloat-store
-DDISABLE_ENSENSO-DDISABLE_DAVIDSDK-DDISABLE_DSSDK-DDISABLE_PCAP-DDISABLE_PNG-DDISABLE_LIBUSB_1_0
Based on some quick research it seems likely that -ffloat-store
is automatically added by PCL based on the detected capabilities of the ARM CPU in the Jetson Xavier NX.
message says:
CMake Warning at CMakeLists.txt:17 (message):
-ffloat-store
-DDISABLE_ENSENSO-DDISABLE_DAVIDSDK-DDISABLE_DSSDK-DDISABLE_PCAP-DDISABLE_PNG-DDISABLE_LIBUSB_1_0
It’s significant that the -ffloat-store
flag is written correctly here. That means that some later step is incorrectly adding the -D
prefix.
I don’t think we’ve seen a -f
flag in PCL_DEFINITIONS
before, so this might be a case that Yak’s CMakeLists.txt doesn’t handle correctly. For PCL 1.9 the contents of PCL_DEFINITIONS
get passed into target_compile_definitions
for the yak_frontend
library at this line, and that might not be the correct way to handle flags like -ffloat-store
. We have a macro to parse mixed options and definitions, so we might need to create something similar to separate mixed flags and definitions.
@duanyongli I was able to replicate this by manually-prepending -ffloat-store
to PCL_DEFINITIONS
. Our target_add_options_and_definitions
macro doesn’t check to see if the prefix is -f
, so -ffloat-store
was incorrectly being added through target_compile_definitions
instead of target_compile_options
. There were also some issues with PCL_DEFINITIONS
being inconsistently-delimited so that multiple flags and definitions would be incorrectly concatenated. As discussed in #9 and #10 this is specifically a problem with PCL 1.8.X and it’s been fixed in PCL 1.9.X and later.
I modified the macro to correctly handle -f
-prefixed options and inconsistent delimiters, and I’ll have a PR with the fix submitted shortly.
@duanyongli Sorry this took a long time to get fixed and merged in. Let us know if you still encounter this problem on the newest version.
2 participants
У меня есть исходный код приложения, написанного на С++, и я просто хочу что-то прокомментировать, используя:
#ifdef 0
...
#endif
И я получаю эту ошибку
ошибка: имена макросов должны быть идентификаторами
Почему это происходит?
Ответ 1
Директива #ifdef используется для проверки наличия символа препроцессора. Стандарт (C11 6.4.2 Identifiers
) требует, чтобы идентификаторы не начинались с цифры:
identifier:
identifier-nondigit
identifier identifier-nondigit
identifier digit
identifier-nondigit:
nondigit
universal-character-name
other implementation-defined characters>
nondigit: one of
_ a b c d e f g h i j k l m
n o p q r s t u v w x y z
A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z
digit: one of
0 1 2 3 4 5 6 7 8 9
Правильная форма использования препроцессора для блокировки кода:
#if 0
: : :
#endif
Вы также можете использовать:
#ifdef NO_CHANCE_THAT_THIS_SYMBOL_WILL_EVER_EXIST
: : :
#endif
но вам нужно быть уверенным, что символы не будут непреднамеренно установлены кодом, отличным от вашего. Другими словами, не используйте что-то вроде NOTUSED
или DONOTCOMPILE
, которое другие могут использовать. Чтобы быть в безопасности, предпочтительнее выбрать #if
.
Ответ 2
Используйте следующее, чтобы оценить выражение (константа 0 принимает значение false).
#if 0
...
#endif
Ответ 3
Эта ошибка также может возникать, если вы не выполняете правила marco
Как
#define 1K 1024 // Macro rules must be identifiers error occurs
Причина: макрос Должен начинаться с буквы, а не числа
Изменить на
#define ONE_KILOBYTE 1024 // This resolves
Ответ 4
Обратите внимание, что вы также можете нажать эту ошибку, если случайно введите:
#define <stdio.h>
… вместо…
#include <stdio.>
Ответ 5
#ifdef 0
...
#endif
#ifdef ожидает макрос, а не выражение
при использовании константы или выражения
#if 0
...
#endif
или
#if !defined(PP_CHECK) || defined(PP_CHECK_OTHER)
..
#endif
если используется #ifdef, он сообщает об этой ошибке
#ifdef !defined(PP_CHECK) || defined(PP_CHECK_OTHER)
..
#endif
Где #ifdef ожидает макрос, а не выражение макроса
Ответ 6
Иногда, если вы копируете код из PDF-документа и вставляете его в свой редактор; скрытые странные символы включены. Таким образом, эта ошибка может также возникать в этой ситуации.
Будьте осторожны. Вы должны заменить все пробелы, скопированные для новых, а также сделать то же самое с возвратом каретки.
Рекомендуемые сообщения
-
- Поделиться
Не компилируются код в arduino, выдает эту ошибку.
Код останавливает на 4ой строке
//Project 8 - быстродействующий термометр
#define 2 COLD
#define 4 NORMAL
#define 6 HOT //вот здесь
....
В чем может быть дело?
- Цитата
Ссылка на комментарий
Поделиться на другие сайты
-
- Поделиться
Местами цифры и названия поменяйте.
- Цитата
Ссылка на комментарий
Поделиться на другие сайты
-
- Поделиться
Для тех хто в танке
#define cold 2
- Цитата
По пятницам мы с коллегой мучаем старые платы (ненужные или не рабочие). Они либо горят либо взрываются.
Ссылка на комментарий
Поделиться на другие сайты
Выгодные LED-драйверы MOSO для индустриальных приложений
Компэл представляет выгодные светодиодные драйверы MOSO для промышленных решений с высоким классом защиты от внешних воздействующих факторов, хорошей устойчивостью к импульсным помехам и высокой надежностью. В ряде серий реализована возможность дистанционного контроля, кроме того, отдельные версии драйверов могут программироваться на работу в автономном режиме по заранее заданному сценарию. Рассмотрим подробнее их характеристики.
Читать статью>>
- Автор
-
- Поделиться
Ссылка на комментарий
Поделиться на другие сайты
Новые источники питания на DIN-рейку класса High End от MORNSUN
Компания MORNSUN разработала новую линейку ИП с креплением на DIN-рейку класса High End. Линейка состоит из двух семейств однофазных ИП, различающихся функционалом (LIMF и LIHF) и одного семейства на трехфазное напряжение (LITF). У всех этих ИП печатная плата с компонентами имеет лаковое покрытие. Продукция работоспособна в температурном диапазоне -40…85ºС (для однофазных) и -30…70ºС (для трехфазных). Кроме того, однофазные ИП соответствуют требованиям ATEX и могут использоваться во взрывоопасных зонах. Семейство LIMF имеет стандартный функционал (ККМ, сухой контакт реле, 150% перегрузочная способность), а семейство LIHF – максимальный функционал с доп. функциями селективной защиты (SFB) и возможностью дистанционного управления (может заменить серию QUINT от Phoenix Contact).
Подробнее >>
Присоединяйтесь к обсуждению
Вы можете написать сейчас и зарегистрироваться позже.
Если у вас есть аккаунт, авторизуйтесь, чтобы опубликовать от имени своего аккаунта.
Примечание: Ваш пост будет проверен модератором, прежде чем станет видимым.
Use the following to evaluate an expression (constant 0 evaluates to false).
#if 0
...
#endif
This error can also occur if you are not following the marco rules
Like
#define 1K 1024 // Macro rules must be identifiers error occurs
Reason: Macro Should begin with a letter, not a number
Change to
#define ONE_KILOBYTE 1024 // This resolves
The #ifdef directive is used to check if a preprocessor symbol is defined. The standard (C11 6.4.2 Identifiers
) mandates that identifiers must not start with a digit:
identifier:
identifier-nondigit
identifier identifier-nondigit
identifier digit
identifier-nondigit:
nondigit
universal-character-name
other implementation-defined characters>
nondigit: one of
_ a b c d e f g h i j k l m
n o p q r s t u v w x y z
A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z
digit: one of
0 1 2 3 4 5 6 7 8 9
The correct form for using the pre-processor to block out code is:
#if 0
: : :
#endif
You can also use:
#ifdef NO_CHANCE_THAT_THIS_SYMBOL_WILL_EVER_EXIST
: : :
#endif
but you need to be confident that the symbols will not be inadvertently set by code other than your own. In other words, don’t use something like NOTUSED
or DONOTCOMPILE
which others may also use. To be safe, the #if
option should be preferred.
Tags:
C++
C Preprocessor
Macros
Related
-
barry53
- CodeLite Curious
- Posts: 2
- Joined: Sat Jun 02, 2012 6:53 am
- Genuine User: Yes
- IDE Question: c++
- Contact:
Error: macro names must be identifiers
Hello,
I’m completely new to CodeLite and C++ so this is probably just an oversite on my part.
CodeLite version: v3.5.5378
Installed from the Ubuntu repositories
My OS is Ubunutu 12.04 Precise
Build Window output:
[code———-Build Started———
/bin/sh -c ‘»make» -j 2 -f «ubnt_wsp.mk»‘
———-Building project:[ ubntinfo — Debug ]———-
make[1]: Entering directory `/home/barry/.codelite/ubnt/ubntinfo’
<command-line>:0:1: error: macro names must be identifiers
make[1]: *** [Debug/main.o.d] Error 1
make[1]: Leaving directory `/home/barry/.codelite/ubnt/ubntinfo’
make: *** [All] Error 2
———-Build Ended———-
0 errors, 0 warnings
[/code]
What I’v done is copy an example program from libssh2.org’s site. It is c code and I’m pasted it into a c++ project.
At this point I’m so new at this I’m not sure what else to post. Let me know what else to post to get a handle on the
<command-line>:0:1: error: macro names must be identifiers
error.
Thanks for your time,
Barry
-
eranif
- CodeLite Plugin
- Posts: 6310
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Error: macro names must be identifiers
Post
by eranif » Mon Jun 04, 2012 6:53 pm
It seems like you have a macro defined somewhere (from the output <command-line> it seems that you defined a macro with invalid name somewhere
Eran
Make sure you have read the HOW TO POST thread
-
barry53
- CodeLite Curious
- Posts: 2
- Joined: Sat Jun 02, 2012 6:53 am
- Genuine User: Yes
- IDE Question: c++
- Contact:
Re: Error: macro names must be identifiers
Post
by barry53 » Sun Jun 10, 2012 5:17 pm
Thanks for your reply Eran.
I too thought it was some invalid macro name, but I hadn’t defined any macros and was using all standard headers. So I decided to start from scratch and as I added a section of code, compiled and if all went well added some more code. To make along story short, when I added <iostream> and used cout and cin the problem occurred again. Well after Googling and the usual debugging effort, I noticed Update Manager had some 70 updates to do. So I let Update Manager do the updates which of course required a restart. After I rebooted everything worked as it should. I don’t know if it was one of the packages that fixed the issue or just the reboot, but anyhow things are working now.
Thanks again for your response,
Barry
starcomputer
Offline
Зарегистрирован: 19.10.2021
Ну и как компилятор отсюда:
UTFT::UTFT(byte model, int RS, int WR, int CS, int RST, int SER) { word dsx[] = {239, 239, 239, 239, 239, 239, 175, 175, 239, 127, // 00-09 127, 239, 271, 479, 239, 239, 239, 239, 239, 239, // 10-19 479, 319, 239, 175, 0, 239, 239, 319, 319, 799, // 20-29 127}; // 30- word dsy[] = {319, 399, 319, 319, 319, 319, 219, 219, 399, 159, // 00-09 127, 319, 479, 799, 319, 319, 319, 319, 319, 319, // 10-19 799, 479, 319, 219, 0, 319, 319, 479, 479, 479, // 20-29 159}; // 30- byte dtm[] = {16, 16, 16, 8, 8, 16, 8, SERIAL_4PIN, 16, SERIAL_5PIN, // 00-09 SERIAL_5PIN, 16, 16, 16, 8, 16, LATCHED_16, 16, 8, 8, // 10-19 16, 16, 16, 8, 0, SERIAL_5PIN, SERIAL_4PIN, 16, 16, 16, // 20-29 SERIAL_5PIN}; // 30- disp_x_size = dsx[model]; disp_y_size = dsy[model]; display_transfer_mode = dtm[model]; display_model = model; __p1 = RS; __p2 = WR; __p3 = CS; __p4 = RST; __p5 = SER; if (display_transfer_mode == SERIAL_4PIN) { display_transfer_mode=1; display_serial_mode=SERIAL_4PIN; } if (display_transfer_mode == SERIAL_5PIN) { display_transfer_mode=1; display_serial_mode=SERIAL_5PIN; } if (display_transfer_mode!=1) { _set_direction_registers(display_transfer_mode); P_RS = portOutputRegister(digitalPinToPort(RS)); B_RS = digitalPinToBitMask(RS); P_WR = portOutputRegister(digitalPinToPort(WR)); B_WR = digitalPinToBitMask(WR); P_CS = portOutputRegister(digitalPinToPort(CS)); B_CS = digitalPinToBitMask(CS); P_RST = portOutputRegister(digitalPinToPort(RST)); B_RST = digitalPinToBitMask(RST); if (display_transfer_mode==LATCHED_16) { P_ALE = portOutputRegister(digitalPinToPort(SER)); B_ALE = digitalPinToBitMask(SER); cbi(P_ALE, B_ALE); pinMode(8,OUTPUT); digitalWrite(8, LOW); } } else { P_SDA = portOutputRegister(digitalPinToPort(RS)); B_SDA = digitalPinToBitMask(RS); P_SCL = portOutputRegister(digitalPinToPort(WR)); B_SCL = digitalPinToBitMask(WR); P_CS = portOutputRegister(digitalPinToPort(CS)); B_CS = digitalPinToBitMask(CS); if (RST != NOTINUSE) { P_RST = portOutputRegister(digitalPinToPort(RST)); B_RST = digitalPinToBitMask(RST); } if (display_serial_mode!=SERIAL_4PIN) { P_RS = portOutputRegister(digitalPinToPort(SER)); B_RS = digitalPinToBitMask(SER); } } }
что-то выкинет ?
А у меня ОДНА модель дисплея. Мне не нужны массивы dtx,dty,dtm. Мне не нужны переменные display_transfer_mode и display_model и связанные с ними if…else. Мне не нужны остальные if…else в зависимости от ориентации дисплея.
Если все это убрать, то:
UTFT::UTFT(byte model, int RS, int WR, int CS, int RST, int SER) { disp_x_size = 479; disp_y_size = 799; __p1 = RS; __p2 = WR; __p3 = CS; __p4 = RST; __p5 = SER; _set_direction_registers(16); P_RS = portOutputRegister(digitalPinToPort(RS)); B_RS = digitalPinToBitMask(RS); P_WR = portOutputRegister(digitalPinToPort(WR)); B_WR = digitalPinToBitMask(WR); P_CS = portOutputRegister(digitalPinToPort(CS)); B_CS = digitalPinToBitMask(CS); P_RST = portOutputRegister(digitalPinToPort(RST)); B_RST = digitalPinToBitMask(RST); }
Если все это писать на директивах препроцессора, то там сам черт голову сломает