GCC 编译 warnings

本文详细介绍了GCC编译过程中遇到的各种警告,包括多字符字符常量警告、未定义的操作警告、类型转换警告、可能不返回的函数警告、字符串常量到char*的转换警告、隐式声明函数警告以及严格别名规则警告。并提供了如何消除或处理这些警告的建议,如使用特定的编译选项和修改代码结构。
摘要由CSDN通过智能技术生成

1. 编译选项-g:Generate debug information when compiling.

2. 优化选项-O0:关闭所有优化选项。

3. Warning:(GCC)

1) Warning: multi-character character constant

Could be suppressed by -Wno-multichar

There're three kinds of character constants: Normal character constants, Multicharacter constants and Wide-character constants.

    char ch = 'a';
    int mbch = '1234';
    wchar_t wcch = L'ab';


Mbch is of type int(signed), has 4 meaningful characters.

Gcc compiler evaluates a multi-character character constant a character at a time, shifting the previous value left by the number of bits per target character, and then or-ing in the bit-pattern of the new character truncated to the width of a target character.

'ab' for a target with an 8-bit char would be interpreted as:</

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值