哪个预处理器是正确的? [英] Which preprocessor is correct?

查看:44
本文介绍了哪个预处理器是正确的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你有:

#define errno retrieve_errno_func()


#define SUBSYSTEM_INCLUDE(子系统,文件)< subsystem / include / file> <那么当你这么做时会发生什么:

#include SUBSYSTEM_INCLUDE(posix,errno.h)


gcc2.95 pre-按预期进行处理:

#include< posix / include / errno.h>


gcc3.4预处理:


#include< posix / include / retrueve_errno_func()>


我的猜测是gcc3.4是正确的,即使它没有

产生预期的结果。

If you have:
#define errno retrieve_errno_func()

#define SUBSYSTEM_INCLUDE(subsystem, file) <subsystem/include/file>
then what should happen when you do:
#include SUBSYSTEM_INCLUDE(posix, errno.h)

gcc2.95 pre-processes as intended, to:

#include <posix/include/errno.h>

gcc3.4 preprocessed to:

#include <posix/include/retrueve_errno_func()>

My guess is that gcc3.4 was the correct one, even though it didn''t
produce the intended result.

推荐答案

7月24日下午4:03,Tomásóhéilidhe < t ... @ lavabit.comwrote:
On Jul 24, 4:03 pm, Tomás ó héilidhe <t...@lavabit.comwrote:

如果你有:


#define errno retrieve_errno_func()
If you have:

#define errno retrieve_errno_func()



除非retrieve_errno_func是一个类似函数的宏,扩展为

可修改的左值,这是错误的。 />

unless retrieve_errno_func is a function-like macro expanding to a
modifiable lvalue, this is wrong.


7月24日,4:18 * pm,vipps ... @ gmail.com写道:
On Jul 24, 4:18*pm, vipps...@gmail.com wrote:

On 7月24日下午4:03,Tomásóhéilidhe< t ... @ lavabit.comwrote:如果你有:
On Jul 24, 4:03 pm, Tomás ó héilidhe <t...@lavabit.comwrote:If you have:

* * #define errno retrieve_errno_func()
* *#define errno retrieve_errno_func()



除非retrieve_errno_func是一个类似函数的宏扩展到

可修改的左值,这是错误的。


unless retrieve_errno_func is a function-like macro expanding to a
modifiable lvalue, this is wrong.



为什么?

Why?


fnegroni schrieb:
fnegroni schrieb:

7月24日下午4:18,vipps ... @ gmail.com写道:
On Jul 24, 4:18 pm, vipps...@gmail.com wrote:

> 7月24日下午4:03,Tomásó héilidhe< t ... @ lavabit.comwrote:如果你有:
>On Jul 24, 4:03 pm, Tomás ó héilidhe <t...@lavabit.comwrote:If you have:

>> #define errno retrieve_errno_func()
>> #define errno retrieve_errno_func()


除非retrieve_errno_func是一个类似函数的宏扩展到可修改的左值,这是错误的。

unless retrieve_errno_func is a function-like macro expanding to a
modifiable lvalue, this is wrong.



为什么?


Why?



因为errno必须是左值可修改的。


errno = 0;

$当errno扩展到
时,b $ b将无法工作

foobar()= 0;


问候,

约翰内斯


-

" Wer etwas kritisiert muss es noch lange nicht selber besser k?nnen。 Es

reicht zu wissen,da? andere es besser k?nnen und andere es auch

besser machen um einen Vergleich zu bringen。 - Wolfgang Gerber

in de.sci.electronics< 47 *********************** @ news.freenet.de>

Because errno has to be lvalue-modifyable.

errno = 0;

will not work when errno expands to

foobar() = 0;

Regards,
Johannes

--
"Wer etwas kritisiert muss es noch lange nicht selber besser k?nnen. Es
reicht zu wissen, da? andere es besser k?nnen und andere es auch
besser machen um einen Vergleich zu bringen." - Wolfgang Gerber
in de.sci.electronics <47***********************@news.freenet.de>


这篇关于哪个预处理器是正确的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆