全局变量名与标准头冲突 [英] global variable name conflict with standard header

查看:85
本文介绍了全局变量名与标准头冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello all

我想给某个全局变量指定一个名字。不幸的是,

这个名字已经在math.h中用于数学函数。更糟糕的是,我确实需要使用数学库,因此必须包含math.h.
需要使用数学库。因此我的编译器

报告相同名称的冲突声明。

有谁知道任何合理优雅的方法来解决这个冲突?我知道我可以放弃并选择其他名字,但不知何故不开心



任何建议都会非常感激!

- V.

Hello all
I would like to give a certain name to a certain global variable. Unfortunately,
this name is already used in math.h for a mathematical function. Worse, I do
need to use maths library and therefore have to include math.h. Thus my compiler
reports conflicting declarations of the same name.
Does anyone know any reasonably elegant way to resolve this conflict? I
understand that I can give up and choose another name, but somehow not happy
with that.
Any advice would be much appreciated!
- V.

推荐答案

Vadim Biktashev于11/08/04写道:
Vadim Biktashev wrote on 11/08/04 :
我想给某个全局变量赋一个名字。
不幸的是,这个名字已经在math.h中用于数学
函数。更糟糕的是,我确实需要使用数学库,因此必须包括
math.h.因此,我的编译器会报告相同名称的冲突声明。
有没有人知道任何合理优雅的方法来解决这个冲突?我明白我可以放弃并选择另一个名字,但不知何故不满意。
I would like to give a certain name to a certain global variable.
Unfortunately, this name is already used in math.h for a mathematical
function. Worse, I do need to use maths library and therefore have to include
math.h. Thus my compiler reports conflicting declarations of the same name.
Does anyone know any reasonably elegant way to resolve this conflict? I
understand that I can give up and choose another name, but somehow not happy
with that.




没办法,你必须改变名字。通常的诀窍是添加一些

有意义的前缀


PREFIX_identifier


(BTW,它不是C问题)


-

Emmanuel

C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html


C是一个锋利的工具



No way, you have to change the name. The usual trick is to add some
meaningful prefix

PREFIX_identifier

(BTW, it''s not a C question)

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

"C is a sharp tool"


Emmanuel Delahaye< em *** @ YOURBRAnoos .FR>写道:
Emmanuel Delahaye <em***@YOURBRAnoos.fr> wrote:
Vadim Biktashev在11/08/04写道:
Vadim Biktashev wrote on 11/08/04 :
我想给某个全局变量赋一个名字。
不幸的是,这个名字已经在math.h中用于数学
函数。更糟糕的是,我确实需要使用数学库,因此必须包括
math.h.因此,我的编译器会报告相同名称的冲突声明。
有没有人知道任何合理优雅的方法来解决这个冲突?我明白我可以放弃并选择另一个名字,但不知何故不满意。
I would like to give a certain name to a certain global variable.
Unfortunately, this name is already used in math.h for a mathematical
function. Worse, I do need to use maths library and therefore have to include
math.h. Thus my compiler reports conflicting declarations of the same name.
Does anyone know any reasonably elegant way to resolve this conflict? I
understand that I can give up and choose another name, but somehow not happy
with that.



没办法,你必须改名。通常的诀窍是添加一些
有意义的前缀

PREFIX_identifier

(顺便说一下,这不是C问题)



No way, you have to change the name. The usual trick is to add some
meaningful prefix

PREFIX_identifier

(BTW, it''s not a C question)




是的,它是:你不能有两个相同的

标识符的冲突声明,因此问题。当然,答案是不要那样做,然后是b $ b,但这并不能让话题成为主题。


Richard



Yes, it is: you cannot have two conflicting declarations of the same
identifier, hence the problem. Of course, the answer is "don''t do that,
then", but that doesn''t make the question off-topic.

Richard


Richard Bos写道:
Richard Bos wrote:
Emmanuel Delahaye< em *** @ YOURBRAnoos.fr>写道:

Emmanuel Delahaye <em***@YOURBRAnoos.fr> wrote:

Vadim Biktashev在11/08/04写道:
Vadim Biktashev wrote on 11/08/04 :
我想给一个名字给一个某个全局变量。不幸的是,这个名字已经在math.h中用于数学
函数。更糟糕的是,我确实需要使用数学库,因此必须包括
math.h.因此,我的编译器会报告相同名称的冲突声明。
有没有人知道任何合理优雅的方法来解决这个冲突?我明白我可以放弃并选择另一个名字,但不知何故不满意。
I would like to give a certain name to a certain global variable.
Unfortunately, this name is already used in math.h for a mathematical
function. Worse, I do need to use maths library and therefore have to include
math.h. Thus my compiler reports conflicting declarations of the same name.
Does anyone know any reasonably elegant way to resolve this conflict? I
understand that I can give up and choose another name, but somehow not happy
with that.



没办法,你必须改名。通常的诀窍是添加一些
有意义的前缀

PREFIX_identifier

(顺便说一下,这不是C问题)



No way, you have to change the name. The usual trick is to add some
meaningful prefix

PREFIX_identifier

(BTW, it''s not a C question)



是的,它是:你不能有两个相同的
标识符的冲突声明,因此问题。当然,答案是不要那样做,然后是,但这并不能使问题成为主题。

理查德


Yes, it is: you cannot have two conflicting declarations of the same
identifier, hence the problem. Of course, the answer is "don''t do that,
then", but that doesn''t make the question off-topic.

Richard



也许,我不够精确。


问题是:有没有办法取消定义/声明

之前,除了打开一个区块并在

区块中创建一个新的定义。我的天真逻辑是,如果有可能是宏,为什么不为普通的C名做一个类似的

的事情。


- Vadim

顺便说一句,如果真的不适合这个新闻组,也许一个善良的灵魂可以直接指向我的b $ b / b


Perhaps, I was not precise enough.

The question is: is there any way to cancel a definition/declaration made
earlier, apart from opening a block and making a new definition local in that
block. My naive logic was, if it is possible for macros, why not make a similar
thing for regular C names.

- Vadim
BTW if this is really not for this newsgroup, perhaps a kind soul could direct
me to the right one?


这篇关于全局变量名与标准头冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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