亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問板塊 發(fā)新帖
查看: 5606 | 回復(fù): 8
打印 上一主題 下一主題

[C] sizeof(long(long))這事啥子意思? [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2014-07-08 11:40 |只看該作者 |倒序?yàn)g覽
sizeof(long(long))這事啥子意思?
求出結(jié)果為1
long(long)怎么解釋?強(qiáng)制轉(zhuǎn)換么?

論壇徽章:
5
獅子座
日期:2013-08-20 10:12:24午馬
日期:2013-11-23 18:04:102015年辭舊歲徽章
日期:2015-03-03 16:54:152015亞冠之德黑蘭石油
日期:2015-06-29 18:11:1115-16賽季CBA聯(lián)賽之新疆
日期:2024-02-21 10:00:53
2 [報(bào)告]
發(fā)表于 2014-07-08 11:55 |只看該作者
long(long)是函數(shù)類型。

函數(shù)類型的大小是實(shí)現(xiàn)定義的(還是未定義?還是別的什么?)反正意思就是取不到,所以給你返回一個(gè)1意思一下。

論壇徽章:
1
2015年迎新春徽章
日期:2015-03-04 09:49:45
3 [報(bào)告]
發(fā)表于 2014-07-08 15:09 |只看該作者
本帖最后由 koolcoy 于 2014-07-08 15:10 編輯

沒記錯(cuò)的話,implementation defined的行為在不同的實(shí)現(xiàn)里行為可能不一樣,但是在同一個(gè)實(shí)現(xiàn)里行為必須一樣,不過具體啥行為由實(shí)現(xiàn)決定,可以當(dāng)作實(shí)現(xiàn)的擴(kuò)展來用。

論壇徽章:
17
處女座
日期:2013-08-27 09:59:352015亞冠之柏太陽(yáng)神
日期:2015-07-30 10:16:402015亞冠之薩濟(jì)拖拉機(jī)
日期:2015-07-29 18:58:182015年亞洲杯之巴勒斯坦
日期:2015-03-06 17:38:17摩羯座
日期:2014-12-11 21:31:34戌狗
日期:2014-07-20 20:57:32子鼠
日期:2014-05-15 16:25:21亥豬
日期:2014-02-11 17:32:05丑牛
日期:2014-01-20 15:45:51丑牛
日期:2013-10-22 11:12:56雙子座
日期:2013-10-18 16:28:17白羊座
日期:2013-10-18 10:50:45
4 [報(bào)告]
發(fā)表于 2014-07-11 14:12 |只看該作者
回復(fù) 1# zheguzai


    這本來是個(gè)錯(cuò)誤的語(yǔ)法,是標(biāo)準(zhǔn)所不允許的,但是gcc的擴(kuò)展允許此用法。

c標(biāo)準(zhǔn)中對(duì)sizeof有如下規(guī)定:6.5.3.4
The sizeof operator shall not be applied to an expression that has function type or an incomplete type, to the parenthesized name of such a type, or to an expression that designates a bit-field member.

根據(jù)上述規(guī)定定function type是不被允許的。

gcc的有如下所述的擴(kuò)展:
5.17 Arithmetic on void- and Function-Pointers

In GNU C, addition and subtraction operations are supported on pointers to void and on pointers to functions. This is done by treating the size of a void or of a function as 1.

A consequence of this is that sizeof is also allowed on void and on function types, and returns 1.

The option -Wpointer-arith requests a warning if these extensions are used.
https://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Pointer-Arith.html#Pointer-Arith

可見之所以返回1是由于gcc的擴(kuò)展影響的結(jié)果。

論壇徽章:
9
摩羯座
日期:2013-08-15 15:18:48獅子座
日期:2013-09-12 18:07:47金牛座
日期:2013-09-16 13:23:09辰龍
日期:2013-10-09 09:03:27白羊座
日期:2013-10-17 13:32:44子鼠
日期:2014-04-23 15:09:38戌狗
日期:2014-09-17 11:37:542015年亞洲杯之韓國(guó)
日期:2015-03-26 10:16:442015亞冠之武里南聯(lián)
日期:2015-08-18 14:55:52
5 [報(bào)告]
發(fā)表于 2014-07-11 14:50 |只看該作者
這個(gè)long(long)沒見過,說是函數(shù)類型,應(yīng)該怎么理解,貌似沒有遇到它的應(yīng)用場(chǎng)景。
long(*)(long)倒是容易理解,是個(gè)函數(shù)指針,sizeof應(yīng)該是4吧,與這個(gè)long(long)應(yīng)該不同。

論壇徽章:
17
處女座
日期:2013-08-27 09:59:352015亞冠之柏太陽(yáng)神
日期:2015-07-30 10:16:402015亞冠之薩濟(jì)拖拉機(jī)
日期:2015-07-29 18:58:182015年亞洲杯之巴勒斯坦
日期:2015-03-06 17:38:17摩羯座
日期:2014-12-11 21:31:34戌狗
日期:2014-07-20 20:57:32子鼠
日期:2014-05-15 16:25:21亥豬
日期:2014-02-11 17:32:05丑牛
日期:2014-01-20 15:45:51丑牛
日期:2013-10-22 11:12:56雙子座
日期:2013-10-18 16:28:17白羊座
日期:2013-10-18 10:50:45
6 [報(bào)告]
發(fā)表于 2014-07-11 16:42 |只看該作者
回復(fù) 5# w_anthony

A function type describes a function with specified return type. A function type is characterized by its return type and the number and types of its parameters. A function type is said to be derived from its return type, and if its return type is T , the function type is sometimes called ‘‘function returning T’’. The construction of a function type from a return type is called ‘‘function type derivation’’.

根據(jù)標(biāo)準(zhǔn)的解釋,一個(gè)函數(shù)類型描述了一個(gè)函數(shù)及其返回值類型,它的特點(diǎn)是具有返回值和參數(shù)。由此可知long(long)實(shí)際上是一個(gè)Type Name,而這個(gè)Type Name指向function type。


論壇徽章:
3
15-16賽季CBA聯(lián)賽之山東
日期:2016-10-30 08:47:3015-16賽季CBA聯(lián)賽之佛山
日期:2016-12-17 00:06:31CU十四周年紀(jì)念徽章
日期:2017-12-03 01:04:02
7 [報(bào)告]
發(fā)表于 2014-07-18 03:41 |只看該作者
回復(fù) 6# myworkstation


    好吧, 語(yǔ)言律師。

論壇徽章:
2
2015年辭舊歲徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:56:11
8 [報(bào)告]
發(fā)表于 2014-07-18 09:26 |只看該作者
好像C99支持函數(shù)類型。以前的不支持吧!

論壇徽章:
17
處女座
日期:2013-08-27 09:59:352015亞冠之柏太陽(yáng)神
日期:2015-07-30 10:16:402015亞冠之薩濟(jì)拖拉機(jī)
日期:2015-07-29 18:58:182015年亞洲杯之巴勒斯坦
日期:2015-03-06 17:38:17摩羯座
日期:2014-12-11 21:31:34戌狗
日期:2014-07-20 20:57:32子鼠
日期:2014-05-15 16:25:21亥豬
日期:2014-02-11 17:32:05丑牛
日期:2014-01-20 15:45:51丑牛
日期:2013-10-22 11:12:56雙子座
日期:2013-10-18 16:28:17白羊座
日期:2013-10-18 10:50:45
9 [報(bào)告]
發(fā)表于 2014-07-19 15:17 |只看該作者
回復(fù) 8# cobras


    支持的,C89就有明確的規(guī)定了。
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP