By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,851 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,851 IT Pros & Developers. It's quick & easy.

Variable name...

P: n/a
Greetings to everyone, this is my odd (probably trivial) question:
i defined that thing, like gobal var
....
int y1 = 0;
....
and at compile time i got
....
C:\Dati\Luigi\Progetti\provec++\plasma\SetPixel.cp p(42) : error C2373: 'y1'
: redefinition; different type modifiers
c:\programmi\microsoft visual studio\vc98\include\math.h(435) : see
declaration of 'y1'
....
then looked at the corresponding line in math.h, that is
....
_CRTIMP double __cdecl y1(double);
....
And i dont have any math.h include around.
Any hint? I'm under VC6, if it helps...
Thank to everyone who will reply me.
Luigi.

Jul 22 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
"Il Maestro" <lu*************@spam.tiscali.it> wrote in
news:EH***********************@news3.tin.it:
Greetings to everyone, this is my odd (probably trivial) question:
i defined that thing, like gobal var
...
int y1 = 0;
...
and at compile time i got
...
C:\Dati\Luigi\Progetti\provec++\plasma\SetPixel.cp p(42) : error C2373:
'y1'
: redefinition; different type modifiers
c:\programmi\microsoft visual studio\vc98\include\math.h(435)
: see
declaration of 'y1'
...
then looked at the corresponding line in math.h, that is
...
_CRTIMP double __cdecl y1(double);
...
And i dont have any math.h include around.
Any hint? I'm under VC6, if it helps...
Thank to everyone who will reply me.
Luigi.


According to the documentation for VC7 (I don't have VC98, that is pretty
old for a C++ compiler), the functions _y0, _y1, and _yn(all with leading
underscores) compute Bessel functions. My copy of math.h shows these
functions both with and without leading underscore, depending on various
preprocessor definitions. I am not sure what exactly controls which is
selected, but maybe this will provide you with some insight.

Gregg
Jul 22 '05 #2

P: n/a

"Il Maestro" <lu*************@spam.tiscali.it> wrote in message
news:EH***********************@news3.tin.it...
Greetings to everyone, this is my odd (probably trivial) question:
i defined that thing, like gobal var
...
int y1 = 0;
...
and at compile time i got
...
C:\Dati\Luigi\Progetti\provec++\plasma\SetPixel.cp p(42) : error C2373: 'y1' : redefinition; different type modifiers
c:\programmi\microsoft visual studio\vc98\include\math.h(435) : see declaration of 'y1'
...
then looked at the corresponding line in math.h, that is
...
_CRTIMP double __cdecl y1(double);
...
And i dont have any math.h include around.
Any hint? I'm under VC6, if it helps...
Thank to everyone who will reply me.
Luigi.


VC6 only turns these names on if you have a macro defined, OLDNAMES I think
it is. So look at your compiler settings and turn that off if its on.

My memory might be playing tricks on me so if that isn't right ask in VC
group, for instance news:microsoft.public.vc.language

john
Jul 22 '05 #3

P: n/a
Il Maestro wrote:

Greetings to everyone, this is my odd (probably trivial) question:
i defined that thing, like gobal var
...
int y1 = 0;
...
and at compile time i got
...
C:\Dati\Luigi\Progetti\provec++\plasma\SetPixel.cp p(42) : error C2373: 'y1'
: redefinition; different type modifiers
c:\programmi\microsoft visual studio\vc98\include\math.h(435) : see
declaration of 'y1'
...
then looked at the corresponding line in math.h, that is
...
_CRTIMP double __cdecl y1(double);
...
And i dont have any math.h include around.
Any hint? I'm under VC6, if it helps...
Thank to everyone who will reply me.
Luigi.


Bessel functions j0, j1, jn, y0, y1, yn are quite common, not only
with MS libraries. Some other header included <math.h>, where they
were declared; e.g., <iostream> does that for me.

It pays to just avoid using simple short names like the above in the
/global scope/ (actually, any names if there is no good reason to the
contrary). Put them into a namespace; an unnamed namespace if you
only need them in a given unit.

Denis
Jul 22 '05 #4

P: n/a
"John Harrison" <jo*************@hotmail.com> wrote in message
news:2h************@uni-berlin.de

VC6 only turns these names on if you have a macro defined, OLDNAMES I
think it is. So look at your compiler settings and turn that off if
its on.

My memory might be playing tricks on me so if that isn't right ask in
VC group, for instance news:microsoft.public.vc.language

Header files are a pain in the neck to interpret in terms of #ifdefs and
such, but it appears that y1 and the rest typically ARE defined.

The main case in which this is NOT true is when the /Za (disable extensions)
compiler switch is set AND it is a C file that is being compiled.

If it is a C++ file, then (with or without /Za) y1 is defined and the
problem arises. It seems that the only practical solution is to NOT have a
variable named y1 (or y0 or yn or a few other things) at global scope.
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)

Jul 22 '05 #5

P: n/a
Ok, i got the point...
I think i'll follow the namespace advice, because i find ilarious i cant use
such a useful name....
Thank to everyone ;)
Jul 22 '05 #6

P: n/a
Denis Remezov <RE*********************@yahoo.removethis.ca> wrote:

Bessel functions j0, j1, jn, y0, y1, yn are quite common, not only
with MS libraries. Some other header included <math.h>, where they
were declared; e.g., <iostream> does that for me.


<iostream> ought to only include <cmath> (or not include either, of course).
If you get y1 in the global namespace as a result of including iostream,
then a compiler upgrade is probably in order.

(Add this one to the list of reasons not to go "using namespace std;")
Jul 22 '05 #7

P: n/a
Old Wolf wrote:

Denis Remezov <RE*********************@yahoo.removethis.ca> wrote:

Bessel functions j0, j1, jn, y0, y1, yn are quite common, not only
with MS libraries. Some other header included <math.h>, where they
were declared; e.g., <iostream> does that for me.


<iostream> ought to only include <cmath> (or not include either, of course).
If you get y1 in the global namespace as a result of including iostream,
then a compiler upgrade is probably in order.


Yes that was what happened. On the hand, y1 is not a standard function,
so placing it in the std namespace would not be the right thing, I assume.

Denis
Jul 22 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.