GCC主要数据结构之cpp_options

本文详细介绍了C/C++预处理器的各种选项及其功能,包括宏处理、字符集设置、警告级别配置等。通过这些选项,用户可以定制预处理行为以符合特定标准或需求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

/* This structure is nested inside struct cpp_reader, and    carries all the options visible to the command line.  */ struct cpp_options {   /* Characters between tab stops.  */   unsigned int tabstop;

  /* The language we're preprocessing.  */   enum c_lang lang;

  /* Nonzero means use extra default include directories for C++.  */   unsigned char cplusplus;

  /* Nonzero means handle cplusplus style comments.  */   unsigned char cplusplus_comments;

  /* Nonzero means define __OBJC__, treat @ as a special token, use      the OBJC[PLUS]_INCLUDE_PATH environment variable, and allow      "#import".  */   unsigned char objc;

  /* Nonzero means don't copy comments into the output file.  */   unsigned char discard_comments;

  /* Nonzero means don't copy comments into the output file during      macro expansion.  */   unsigned char discard_comments_in_macro_exp;

  /* Nonzero means process the ISO trigraph sequences.  */   unsigned char trigraphs;

  /* Nonzero means process the ISO digraph sequences.  */   unsigned char digraphs;

  /* Nonzero means to allow hexadecimal floats and LL suffixes.  */   unsigned char extended_numbers;

  /* Nonzero means process u/U prefix literals (UTF-16/32).  */   unsigned char uliterals;

  /* Nonzero means process u8 prefixed character literals (UTF-8).  */   unsigned char utf8_char_literals;

  /* Nonzero means process r/R raw strings.  If this is set, uliterals      must be set as well.  */   unsigned char rliterals;

  /* Nonzero means print names of header files (-H).  */   unsigned char print_include_names;

  /* Nonzero means complain about deprecated features.  */   unsigned char cpp_warn_deprecated;

  /* Nonzero means warn if slash-star appears in a comment.  */   unsigned char warn_comments;

  /* Nonzero means to warn about __DATA__, __TIME__ and __TIMESTAMP__ usage.   */   unsigned char warn_date_time;

  /* Nonzero means warn if a user-supplied include directory does not      exist.  */   unsigned char warn_missing_include_dirs;

  /* Nonzero means warn if there are any trigraphs.  */   unsigned char warn_trigraphs;

  /* Nonzero means warn about multicharacter charconsts.  */   unsigned char warn_multichar;

  /* Nonzero means warn about various incompatibilities with      traditional C.  */   unsigned char cpp_warn_traditional;

  /* Nonzero means warn about long long numeric constants.  */   unsigned char cpp_warn_long_long;

  /* Nonzero means warn about text after an #endif (or #else).  */   unsigned char warn_endif_labels;

  /* Nonzero means warn about implicit sign changes owing to integer      promotions.  */   unsigned char warn_num_sign_change;

  /* Zero means don't warn about __VA_ARGS__ usage in c89 pedantic mode.      Presumably the usage is protected by the appropriate #ifdef.  */   unsigned char warn_variadic_macros;

  /* Nonzero means warn about builtin macros that are redefined or      explicitly undefined.  */   unsigned char warn_builtin_macro_redefined;

  /* Nonzero means we should look for header.gcc files that remap file      names.  */   unsigned char remap;

  /* Zero means dollar signs are punctuation.  */   unsigned char dollars_in_ident;

  /* Nonzero means UCNs are accepted in identifiers.  */   unsigned char extended_identifiers;

  /* True if we should warn about dollars in identifiers or numbers      for this translation unit.  */   unsigned char warn_dollars;

  /* Nonzero means warn if undefined identifiers are evaluated in an #if.  */   unsigned char warn_undef;

  /* Nonzero means warn of unused macros from the main file.  */   unsigned char warn_unused_macros;

  /* Nonzero for the 1999 C Standard, including corrigenda and amendments.  */   unsigned char c99;

  /* Nonzero if we are conforming to a specific C or C++ standard.  */   unsigned char std;

  /* Nonzero means give all the error messages the ANSI standard requires.  */   unsigned char cpp_pedantic;

  /* Nonzero means we're looking at already preprocessed code, so don't      bother trying to do macro expansion and whatnot.  */   unsigned char preprocessed;     /* Nonzero means we are going to emit debugging logs during      preprocessing.  */   unsigned char debug;

  /* Nonzero means we are tracking locations of tokens involved in      macro expansion. 1 Means we track the location in degraded mode      where we do not track locations of tokens resulting from the      expansion of arguments of function-like macro.  2 Means we do      track all macro expansions. This last option is the one that      consumes the highest amount of memory.  */   unsigned char track_macro_expansion;

  /* Nonzero means handle C++ alternate operator names.  */   unsigned char operator_names;

  /* Nonzero means warn about use of C++ alternate operator names.  */   unsigned char warn_cxx_operator_names;

  /* True for traditional preprocessing.  */   unsigned char traditional;

  /* Nonzero for C++ 2011 Standard user-defined literals.  */   unsigned char user_literals;

  /* Nonzero means warn when a string or character literal is followed by a      ud-suffix which does not beging with an underscore.  */   unsigned char warn_literal_suffix;

  /* Nonzero means interpret imaginary, fixed-point, or other gnu extension      literal number suffixes as user-defined literal number suffixes.  */   unsigned char ext_numeric_literals;

  /* Nonzero means extended identifiers allow the characters specified      in C11 and C++11.  */   unsigned char c11_identifiers;

  /* Nonzero for C++ 2014 Standard binary constants.  */   unsigned char binary_constants;

  /* Nonzero for C++ 2014 Standard digit separators.  */   unsigned char digit_separators;

  /* Holds the name of the target (execution) character set.  */   const char *narrow_charset;

  /* Holds the name of the target wide character set.  */   const char *wide_charset;

  /* Holds the name of the input character set.  */   const char *input_charset;

  /* The minimum permitted level of normalization before a warning      is generated.  See enum cpp_normalize_level.  */   int warn_normalize;

  /* True to warn about precompiled header files we couldn't use.  */   bool warn_invalid_pch;

  /* True if dependencies should be restored from a precompiled header.  */   bool restore_pch_deps;

  /* True if warn about differences between C90 and C99.  */   signed char cpp_warn_c90_c99_compat;

  /* True if warn about differences between C++98 and C++11.  */   bool cpp_warn_cxx11_compat;

  /* Dependency generation.  */   struct   {     /* Style of header dependencies to generate.  */     enum cpp_deps_style style;

    /* Assume missing files are generated files.  */     bool missing_files;

    /* Generate phony targets for each dependency apart from the first        one.  */     bool phony_targets;

    /* If true, no dependency is generated on the main file.  */     bool ignore_main_file;

    /* If true, intend to use the preprocessor output (e.g., for compilation)        in addition to the dependency info.  */     bool need_preprocessor_output;   } deps;

  /* Target-specific features set by the front end or client.  */

  /* Precision for target CPP arithmetic, target characters, target      ints and target wide characters, respectively.  */   size_t precision, char_precision, int_precision, wchar_precision;

  /* True means chars (wide chars) are unsigned.  */   bool unsigned_char, unsigned_wchar;

  /* True if the most significant byte in a word has the lowest      address in memory.  */   bool bytes_big_endian;

  /* Nonzero means __STDC__ should have the value 0 in system headers.  */   unsigned char stdc_0_in_system_headers;

  /* True disables tokenization outside of preprocessing directives. */   bool directives_only;

  /* True enables canonicalization of system header file paths. */   bool canonical_system_headers; };

 
 
#THIS FILE IS AUTO GENERATED FROM THE TEMPLATE! DO NOT CHANGE! set(CMAKE_SYSTEM_NAME Generic) set(CMAKE_SYSTEM_VERSION 1) cmake_minimum_required(VERSION 3.28) # specify cross-compilers and tools set(CMAKE_C_COMPILER arm-none-eabi-gcc) set(CMAKE_CXX_COMPILER arm-none-eabi-g++) set(CMAKE_ASM_COMPILER arm-none-eabi-gcc) set(CMAKE_AR arm-none-eabi-ar) set(CMAKE_OBJCOPY arm-none-eabi-objcopy) set(CMAKE_OBJDUMP arm-none-eabi-objdump) set(SIZE arm-none-eabi-size) set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) # project settings project(untitled C CXX ASM) set(CMAKE_CXX_STANDARD 17) set(CMAKE_C_STANDARD 11) #Uncomment for hardware floating point #add_compile_definitions(ARM_MATH_CM4;ARM_MATH_MATRIX_CHECK;ARM_MATH_ROUNDING) #add_compile_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16) #add_link_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16) #Uncomment for software floating point #add_compile_options(-mfloat-abi=soft) add_compile_options(-mcpu=cortex-m7 -mthumb -mthumb-interwork) add_compile_options(-ffunction-sections -fdata-sections -fno-common -fmessage-length=0) # uncomment to mitigate c++17 absolute addresses warnings #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-register") # Enable assembler files preprocessing add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-x$<SEMICOLON>assembler-with-cpp>) if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") message(STATUS "Maximum optimization for speed") add_compile_options(-Ofast) elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") message(STATUS "Maximum optimization for speed, debug info included") add_compile_options(-Ofast -g) elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel") message(STATUS "Maximum optimization for size") add_compile_options(-Os) else () message(STATUS "Minimal optimization, debug info included") add_compile_options(-Og -g) endif () include_directories(Core/Inc Drivers/STM32H7xx_HAL_Driver/Inc Drivers/STM32H7xx_HAL_Driver/Inc/Legacy Drivers/CMSIS/Device/ST/STM32H7xx/Include Drivers/CMSIS/Include) add_definitions(-DDEBUG -DUSE_HAL_DRIVER -DSTM32H743xx) file(GLOB_RECURSE SOURCES "Core/*.*" "Drivers/*.*") set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/STM32H743XIHX_FLASH.ld) add_link_options(-Wl,-gc-sections,--print-memory-usage,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map) add_link_options(-mcpu=cortex-m7 -mthumb -mthumb-interwork) add_link_options(-T ${LINKER_SCRIPT}) add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT}) set(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex) set(BIN_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.bin) add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_FILE} COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${PROJECT_NAME}.elf> ${BIN_FILE} COMMENT "Building ${HEX_FILE} Building ${BIN_FILE}")
03-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值