Options Controlling C Dialect

本文介绍 GCC 编译器中控制 C 语言方言的标准选项,包括如何使用 -ansi 和 -std 选项来指定 ISO C 标准,以及如何通过 -fno-asm 禁用特定的关键字。此外还提供了预处理和编译过程的分离方法。

3.4 Options Controlling C Dialect

The following options control the dialect of C (or languages derivedfrom C, such as C++ and Objective-C) that the compiler accepts:

-ansi
In C mode, support all ISO C90 programs. In C++ mode,remove GNU extensions that conflict with ISO C++.

This turns off certain features of GCC that are incompatible with ISOC90 (when compiling C code), or of standard C++ (when compiling C++ code),such as the asm and typeof keywords, andpredefined macros such as unix and vax that identify thetype of system you are using. It also enables the undesirable andrarely used ISO trigraph feature. For the C compiler,it disables recognition of C++ style `//' comments as well asthe inline keyword.

The alternate keywords __asm__, __extension__,__inline__ and __typeof__ continue to work despite-ansi. You would not want to use them in an ISO C program, ofcourse, but it is useful to put them in header files that might be includedin compilations done with -ansi. Alternate predefined macrossuch as __unix__ and __vax__ are also available, with orwithout -ansi.

The -ansi option does not cause non-ISO programs to berejected gratuitously. For that, -pedantic is required inaddition to -ansi. See Warning Options.

The macro __STRICT_ANSI__ is predefined when the -ansioption is used. Some header files may notice this macro and refrainfrom declaring certain functions or defining certain macros that theISO standard doesn't call for; this is to avoid interfering with anyprograms that might use these names for other things.

Functions which would normally be built in but do not have semanticsdefined by ISO C (such as alloca and ffs) are not built-infunctions with -ansi is used. See Other built-in functions provided by GCC, for details of the functionsaffected.

-std=
Determine the language standard. This option is currently onlysupported when compiling C or C++. A value for this option must beprovided; possible values are
` c89' ` iso9899:1990'
ISO C90 (same as -ansi).
` iso9899:199409'
ISO C90 as modified in amendment 1.
` c99' ` c9x' ` iso9899:1999' ` iso9899:199x'
ISO C99. Note that this standard is not yet fully supported; see http://gcc.gnu.org/gcc-3.4/c99status.html for more information. Thenames ` c9x' and ` iso9899:199x' are deprecated.
` gnu89'
Default, ISO C90 plus GNU extensions (including some C99 features).
` gnu99' ` gnu9x'
ISO C99 plus GNU extensions. When ISO C99 is fully implemented in GCC,this will become the default. The name ` gnu9x' is deprecated.
` c++98'
The 1998 ISO C++ standard plus amendments.
` gnu++98'
The same as -std=c++98 plus GNU extensions. This is thedefault for C++ code.

Even when this option is not specified, you can still use some of thefeatures of newer standards in so far as they do not conflict withprevious C standards. For example, you may use __restrict__ evenwhen -std=c99 is not specified.

The -std options specifying some version of ISO C have the sameeffects as -ansi, except that features that were not in ISO C90but are in the specified version (for example, `//' comments andthe inline keyword in ISO C99) are not disabled.

See Language Standards Supported by GCC, for details ofthese standard versions.

-aux-info filename
Output to the given filename prototyped declarations for all functionsdeclared and/or defined in a translation unit, including those in headerfiles. This option is silently ignored in any language other than C.

Besides declarations, the file indicates, in comments, the origin ofeach declaration (source file and line), whether the declaration wasimplicit, prototyped or unprototyped (`I', `N' for new or`O' for old, respectively, in the first character after the linenumber and the colon), and whether it came from a declaration or adefinition (`C' or `F', respectively, in the followingcharacter). In the case of function definitions, a K&R-style list ofarguments followed by their declarations is also provided, insidecomments, after the declaration.

-fno-asm
Do not recognize asm, inline or typeof as akeyword, so that code can use these words as identifiers. You can usethe keywords __asm__, __inline__ and __typeof__instead. -ansi implies -fno-asm.

In C++, this switch only affects the typeof keyword, sinceasm and inline are standard keywords. You may want touse the -fno-gnu-keywords flag instead, which has the sameeffect. In C99 mode (-std=c99 or -std=gnu99), thisswitch only affects the asm and typeof keywords, sinceinline is a standard keyword in ISO C99.

-fno-builtin -fno-builtin- function
Don't recognize built-in functions that do not begin with` __builtin_' as prefix. See Other built-in functions provided by GCC, for details of the functions affected,including those which are not built-in functions when -ansi or -std options for strict ISO C conformance are used because theydo not have an ISO standard meaning.

GCC normally generates special code to handle certain built-in functionsmore efficiently; for instance, calls to alloca may become singleinstructions that adjust the stack directly, and calls to memcpymay become inline copy loops. The resulting code is often both smallerand faster, but since the function calls no longer appear as such, youcannot set a breakpoint on those calls, nor can you change the behaviorof the functions by linking with a different library.

With the -fno-builtin-function optiononly the built-in function function isdisabled. function must not begin with `__builtin_'. If afunction is named this is not built-in in this version of GCC, thisoption is ignored. There is no corresponding-fbuiltin-function option; if you wish to enablebuilt-in functions selectively when using -fno-builtin or-ffreestanding, you may define macros such as:

          #define abs(n)          __builtin_abs ((n))
          #define strcpy(d, s)    __builtin_strcpy ((d), (s))
     

-fhosted
Assert that compilation takes place in a hosted environment. This implies -fbuiltin. A hosted environment is one in which theentire standard library is available, and in which main has a returntype of int. Examples are nearly everything except a kernel. This is equivalent to -fno-freestanding.
-ffreestanding
Assert that compilation takes place in a freestanding environment. Thisimplies -fno-builtin. A freestanding environmentis one in which the standard library may not exist, and program startup maynot necessarily be at main. The most obvious example is an OS kernel. This is equivalent to -fno-hosted.

See Language Standards Supported by GCC, for details offreestanding and hosted environments.

-fms-extensions
Accept some non-standard constructs used in Microsoft header files.
-trigraphs
Support ISO C trigraphs. The -ansi option (and -stdoptions for strict ISO C conformance) implies -trigraphs.
-no-integrated-cpp
Performs a compilation in two passes: preprocessing and compiling. Thisoption allows a user supplied "cc1", "cc1plus", or "cc1obj" via the -B option. The user supplied compilation step can then add inan additional preprocessing step after normal preprocessing but beforecompiling. The default is to use the integrated cpp (internal cpp)

The semantics of this option will change if "cc1", "cc1plus", and"cc1obj" are merged.


-traditional -traditional-cpp
Formerly, these options caused GCC to attempt to emulate a pre-standardC compiler. They are now only supported with the -E switch. The preprocessor continues to support a pre-standard mode. See the GNUCPP manual for details.
-fcond-mismatch
Allow conditional expressions with mismatched types in the second andthird arguments. The value of such an expression is void. This optionis not supported for C++.
-funsigned-char
Let the type char be unsigned, like unsigned char.

Each kind of machine has a default for what char shouldbe. It is either like unsigned char by default or likesigned char by default.

Ideally, a portable program should always use signed char orunsigned char when it depends on the signedness of an object. But many programs have been written to use plain char andexpect it to be signed, or expect it to be unsigned, depending on themachines they were written for. This option, and its inverse, let youmake such a program work with the opposite default.

The type char is always a distinct type from each ofsigned char or unsigned char, even though its behavioris always just like one of those two.

-fsigned-char
Let the type char be signed, like signed char.

Note that this is equivalent to -fno-unsigned-char, which isthe negative form of -funsigned-char. Likewise, the option-fno-signed-char is equivalent to -funsigned-char.

-fsigned-bitfields -funsigned-bitfields -fno-signed-bitfields -fno-unsigned-bitfields
These options control whether a bit-field is signed or unsigned, when thedeclaration does not use either signed or unsigned. Bydefault, such a bit-field is signed, because this is consistent: thebasic integer types such as int are signed types.
-fwritable-strings
Store string constants in the writable data segment and don't uniquizethem. This is for compatibility with old programs which assume they canwrite into string constants.

Writing into string constants is a very bad idea; “constants” shouldbe constant.

This option is deprecated.

已经博主授权,源码转载自 https://pan.quark.cn/s/fb533687a163 《C++经典代码大全》是一部专门针对C++入门者的重要参考资料,其核心目标在于提供易于理解的C++编程范例,旨在协助新学者迅速领会C++语言的关键概念与技术要点。此压缩文件所包含的信息或许涵盖了从基础到高级的各类C++编程技巧,涉及面向对象编程中的类与对象、函数的应用、程序流程控制、数据结构设计、模板技术以及异常管理等多个关键领域。 1. **基础语法** - 变量声明与初始化:掌握如何声明并初始化不同数据类型的变量,例如整型(int)、浮点型(float)、字符型(char)等。 - 基本输入输出:学习运用`std::cin`和`std::cout`执行标准数据输入与输出操作。 - 控制流语句:熟练运用条件语句(if、if-else、switch-case)以及循环语句(for、while、do-while)来控制程序流程。 2. **类与对象** - 类的定义:学会如何构建类,包含其成员变量与成员函数的设定。 - 对象的创建与使用:掌握如何实例化对象,并经由对象访问类的成员函数。 - 封装:理解封装的理念,并学习使用private和public访问修饰符来保护数据。 - 构造函数与析构函数:掌握如何为类定义自定义的构造过程与析构过程。 3. **函数** - 函数的定义与调用:理解函数的功能与作用,以及如何进行函数的定义和调用。 - 函数参数:精通不同类型的参数传递方法,包括值传递和引用传递。 - 函数重载:学习在同一作用域内定义多个具有相同名称但参数列表不同的函数。 - 函数指针:了解函数指针的运用方法,及其在回调函数和模板中的应用场景。 4. **数组与字符串** -...
内容概要:本文研究了一种计及自适应预测修正的微电网模型预测控制(MPC)优化调度方法,并提供了Matlab代码实现。该方法针对微电网中风电出力等可再生能源的强不确定性,引入自适应预测修正机制,动态调整预测模型以提升短期功率预测精度,从而增强调度决策的准确性与系统运行的鲁棒性。研究构建了完整的MPC滚动优化框架,涵盖预测模型建立、多时间尺度优化求解、实时反馈校正等关键环节,实现了系统运行成本最小化、能源高效利用与功率平衡的多重目标。所提方法有效应对了负荷波动与新能源出力随机性带来的调度挑战,提升了微电网能量管理系统的智能化水平。; 适合人群:具备电力系统、自动化、控制理论或相关领域基础知识的研究生、科研人员及工程技术人员,尤其适合从事微电网优化、可再生能源集成、模型预测控制研究的专业人士,熟悉Matlab编程与优化算法者更佳。; 使用场景及目标:①应用于高比例可再生能源接入的微电网能量管理系统,提升调度方案的实时性与鲁棒性;②为不确定性环境下电力系统动态优化控制策略的研究提供仿真验证平台;③支持学术论文复现、科研课题攻关及实际工程项目的前期技术验证与方案预研。; 阅读建议:建议结合Matlab代码逐模块分析算法实现细节,重点关注预测模型构建与反馈修正机制的设计逻辑,通过调整风电出力、负荷需求等场景参数进行仿真实验,深入理解MPC在微电网调度中的滚动优化特性与自适应修正能力。
代码下载链接: https://pan.quark.cn/s/a4b39357ea24 在信息技术领域中,字符编码扮演着处理文本数据的核心角色。本文着重研究在微控制器系统中,运用C语言如何将UTF-8编码格式转换为GBK编码格式,旨在处理串口通信、TF卡存储或LCD显示屏上可能出现的中文显示错误问题。我们将详细剖析UTF-8与GBK编码的运作机制,并研究基于Keil开发平台的C语言实现流程。 UTF-8是一种被广泛接纳的Unicode字符编码方案,它采用可变长度的字节序列来表示字符,每个Unicode字符都对应一个独一无二的数字标识,即码点。UTF-8的一个显著特点是对ASCII字符(英文文本)保持不变,因此在网络传输和文件存储方面展现出优秀的兼容性。 GBK编码,正式名称为“汉字内码扩展规范”,是中国大陆的标准化编码,是对GB2312编码的延伸,总共涵盖了20902个汉字及其他符号,每个字符使用两个字节来表示。GBK在GB2312的基础上扩充了许多繁体字、少数民族文字以及特殊符号,目的是满足更广泛的语言需求。 将UTF-8转换为GBK的主要难点在于GBK是一种固定长度的双字节编码,而UTF-8则是可变长度的编码。转换过程中需要将UTF-8的多字节序列解析为相应的Unicode码点,然后依据GBK的编码规则查找匹配的编码。这一过程通常借助查表法完成,即建立一个从Unicode码点到GBK编码的映射库。 在Keil开发环境中,使用C语言实现UTF-8到GBK的转换可以遵循以下步骤: 1. **构建查表法所需的GBK编码库**:需要准备一个包含所有GBK字符二进制形式的GBK编码库。这个库通常是一个二进制文件,其大小大约为41KB。 2. **解析UTF-8编码**...
内容概要:本文提出一种基于CNN-BiGRU-Attention混合神经网络模型的风电功率预测方法,旨在提升风力发电功率预测的精度。该模型面向多变量输入的单步预测任务,首先利用卷积神经网络(CNN)提取风速、风向、温度等气象因素的局部时空特征,再通过双向门控循环单元(BiGRU)充分捕捉时间序列数据的前后向时序依赖关系,最终引入注意力(Attention)机制对关键历史时刻的特征进行自适应加权,强化对预测结果贡献更大的时间步信息,从而显著提高预测准确性。整个模型在Matlab平台上实现,特别适用于处理风电数据固有的强随机性与剧烈波动性,能够有效应对复杂多变气象条件下的功率预测挑战,为电网调度提供高精度的数据支撑。; 适合人群:具备一定机器学习和深度学习理论基础,熟悉Matlab编程语言,从事新能源发电预测、电力系统调度、智能算法开发与应用等相关领域的科研人员、工程技术人员及高校研究生。; 使用场景及目标:①应用于风电场实际运行中的短期功率预测,为电网的安全稳定调度与经济运行提供可靠依据;②作为深度学习在可再生能源预测领域应用的典型案例,帮助学习者深入理解CNN、RNN变体(BiGRU)及Attention机制的协同建模原理与实现方法;③为后续研究多步预测、模型轻量化或网络结构优化等方向提供坚实的技术参考和可复用的代码基础。; 阅读建议:学习者应重点关注模型各组件的设计思路与集成方式,结合提供的Matlab代码,系统掌握数据预处理、模型搭建、训练流程及性能验证的完整环节,建议通过调整输入变量组合、优化网络超参数或替换数据集等方式,观察模型性能变化,以深入理解该混合架构的核心优势与调优策略。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值