FD_SET编译器警告,为什么那个特别的warniing? [英] FD_SET compiler warning, why that particular warniing?

查看:124
本文介绍了FD_SET编译器警告,为什么那个特别的warniing?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个程序中有一个编辑错误给这一行(两个

左括号,一个右):


FD_SET((ncmd- > cmd_in_fd,& read_set);


编译时使用


gcc -Wall -pedantic -stc = c99


它为该行号发出此警告:


错误:''FD_SET''未声明(首次使用此功能)

>
没有任何争论说代码行是错误的。我很好奇

虽然为什么编译器会选择发出特定的消息。

这是最令人困惑的,因为FD_SET呼叫在此之前和之后,

并且它们没有产生这些未声明的警告。


问候,

David Mathog

解决方案

David Mathog写道:


我的一个程序中有一个编辑错误给出了这一行(两个

左括号,右边一个):


FD_SET((ncmd-> cmd_in_fd,& read_set);


编译为


gcc -Wall -pedantic -stc = c99


它为该行号发出此警告:


错误:''FD_SET''未声明(在此函数中首次使用)


没有争论说代码行是错误的。我很好奇

虽然为什么编译器会选择发出那条特定的消息。

由于FD_SET调用之前和之后都是最令人困惑的,

并且他们没有产生这些未声明的警告。



如何定义FD_SET?


在文章< fk ********* *@naig.caltech.edu>,

David Mathog< ma **** @ caltech.eduwrote:


>那里在我的一个程序中给出了这一行的编辑错误(两个
左括号,一个右):


FD_SET((ncmd- > cmd_in_fd,& read_set);


>使用
编译时


gcc -Wall -pedantic -stc = c99


>它为该行号发出此警告:


错误:''FD_SET''未声明(在此函数中首次使用)


> ;没有任何争论说代码行是wro我很好奇
虽然为什么编译器会选择发出那个特定的消息。
这是最令人困惑的,因为FD_SET调用先于和跟随这个,
并且他们没有生成这些未申报"警告。



假设FD_SET是一个类似于对象的宏,那么由于缺少

括号,该行不是类似于对象的调用宏

因此FD_SET不会被识别为该行的宏名称。

-

所以你找到了你的解决方案

你最后的贡献是什么?

- Supertramp(傻瓜的序曲)


ro ****** @ ibd.nrc-cnrc.gc.ca (Walter Roberson)写道:< br>


文章< fk ********** @ naig.caltech.edu>,

David Mathog< ma****@caltech.eduwrote:


>>我的一个程序中有一个编辑错误给出了这一行(两个
左括号,右边一个):


> FD_SET((ncmd-> cmd_in_fd,& read_set);


>>使用
编译时

< blockquote class =post_quotes>
> gcc -Wall -pedantic -stc = c99


>>它发出此警告对于该行号:


>错误:''FD_SET''未声明(首次在此函数中使用)


>>没有争论说代码行是错误的。我很好奇
虽然为什么编译器会选择发出特定的消息。<由于FD_SET调用之前和之后都是最令人困惑的,
并且他们没有生成这些未声明的警告。



假设FD_SET是一个类似对象的宏,然后由于缺少

括号,该行不是类似对象的调用宏的阳离子

因此FD_SET不会被识别为该行的宏名称。



这没有意义。要扩展,一个类似对象的宏

不需要跟随任何特定的令牌。如果你实际上意味着类似函数的宏,那么预处理器将继续从

源文件的后续行读取参数
;在同一条线上没有右括号

不会阻止它扩展

宏的想法。

-

在我的Egotistical Opinion中,大多数人的C程序应该向下缩进六英尺b $ b英尺向下并覆盖着污垢。 - Blair P. Houghton


There was an editing error in one of my programs giving this line (two
left parentheses, one right):

FD_SET((ncmd->cmd_in_fd,&read_set);

When compiled with

gcc -Wall -pedantic -stc=c99

it issued this warning for that line number:

error: ''FD_SET'' undeclared (first use in this function)

There''s no argument that the line of code was wrong. I am curious
though why a compiler would choose to emit that particular message.
It was most confusing since FD_SET calls preceded and followed this one,
and they were not generating these "undeclared" warnings.

Regards,

David Mathog

解决方案

David Mathog wrote:

There was an editing error in one of my programs giving this line (two
left parentheses, one right):

FD_SET((ncmd->cmd_in_fd,&read_set);

When compiled with

gcc -Wall -pedantic -stc=c99

it issued this warning for that line number:

error: ''FD_SET'' undeclared (first use in this function)

There''s no argument that the line of code was wrong. I am curious
though why a compiler would choose to emit that particular message.
It was most confusing since FD_SET calls preceded and followed this one,
and they were not generating these "undeclared" warnings.

How is FD_SET defined?


In article <fk**********@naig.caltech.edu>,
David Mathog <ma****@caltech.eduwrote:

>There was an editing error in one of my programs giving this line (two
left parentheses, one right):

FD_SET((ncmd->cmd_in_fd,&read_set);

>When compiled with

gcc -Wall -pedantic -stc=c99

>it issued this warning for that line number:

error: ''FD_SET'' undeclared (first use in this function)

>There''s no argument that the line of code was wrong. I am curious
though why a compiler would choose to emit that particular message.
It was most confusing since FD_SET calls preceded and followed this one,
and they were not generating these "undeclared" warnings.

Suppose FD_SET is an object-like macro, then because of the missing
bracket, the line is not an object-like invocation of the macro
and so FD_SET would not be recognized as a macro name on that line.
--
So you found your solution
What will be your last contribution?
-- Supertramp (Fool''s Overture)


ro******@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes:

In article <fk**********@naig.caltech.edu>,
David Mathog <ma****@caltech.eduwrote:

>>There was an editing error in one of my programs giving this line (two
left parentheses, one right):

> FD_SET((ncmd->cmd_in_fd,&read_set);

>>When compiled with

> gcc -Wall -pedantic -stc=c99

>>it issued this warning for that line number:

> error: ''FD_SET'' undeclared (first use in this function)

>>There''s no argument that the line of code was wrong. I am curious
though why a compiler would choose to emit that particular message.
It was most confusing since FD_SET calls preceded and followed this one,
and they were not generating these "undeclared" warnings.


Suppose FD_SET is an object-like macro, then because of the missing
bracket, the line is not an object-like invocation of the macro
and so FD_SET would not be recognized as a macro name on that line.

That doesn''t make sense. To be expanded, an object-like macro
doesn''t need to be followed by any particular token. And if you
actually meant function-like macro, then the preprocessor would
continue reading the arguments from succeeding lines of the
source file; the lack of a right parenthesis on the same line
would not dissuade it from the idea that it was expanding a
macro.
--
"In My Egotistical Opinion, most people''s C programs should be indented six
feet downward and covered with dirt." -- Blair P. Houghton


这篇关于FD_SET编译器警告,为什么那个特别的warniing?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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