valarray in .NET 
Author Message
 valarray in .NET

Hello, I'm not sure if this is the right newsgroup to post to, but I
couldn't find a microsoft group that is really active on this issue.

I'm getting problems when trying to compile code that uses valarrays.  I'm
adding this code to an existing project.  But this problem doesn't exist if
I start a new project and have the code there.  So I'm thinking it's
something to do with the project compiler options.  So I check those between
the one that compiles and the one that doesn't, and they are identical.  For
example:

int main() {
    int a[] = {1,2,3};
    valarray<int> v(a, 3);
    return 0;

Quote:
}

the compiler would give this error message:
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\valarray(309):
error C2059: syntax error : 'function-style cast'
and the code block that it finds offensive is:
L309--->_Ty min() const
{ // return smallest of all elements
    _Ty _Min = _Myptr[0];
    for (size_t _Idx = 0; ++_Idx < size(); )
        if (_Myptr[_Idx] < _Min)
            _Min = _Myptr[_Idx];
    return (_Min);

Quote:
}

I'm really stuck.  Of course I don't have this problem in g++ under cygwin,
but I need to use Visual Studios for my project.  Thanks in advance.

Kevin



Sat, 17 Dec 2005 02:52:52 GMT  
 valarray in .NET
Put

#define NOMINMAX

before including any standard Windows headers such as <windows.h>. Some
Windows header defines min and max as macros unless NOMINMAX is defined.
This wreaks havoc with STL code.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Hello, I'm not sure if this is the right newsgroup to post to, but I
> couldn't find a microsoft group that is really active on this issue.

> I'm getting problems when trying to compile code that uses valarrays.
I'm
> adding this code to an existing project.  But this problem doesn't
exist if
> I start a new project and have the code there.  So I'm thinking it's
> something to do with the project compiler options.  So I check those
between
> the one that compiles and the one that doesn't, and they are
identical.  For
> example:

> int main() {
>     int a[] = {1,2,3};
>     valarray<int> v(a, 3);
>     return 0;
> }

> the compiler would give this error message:
> c:\Program Files\Microsoft Visual Studio

.NET\Vc7\include\valarray(309):

- Show quoted text -

Quote:
> error C2059: syntax error : 'function-style cast'
> and the code block that it finds offensive is:
> L309--->_Ty min() const
> { // return smallest of all elements
>     _Ty _Min = _Myptr[0];
>     for (size_t _Idx = 0; ++_Idx < size(); )
>         if (_Myptr[_Idx] < _Min)
>             _Min = _Myptr[_Idx];
>     return (_Min);
> }

> I'm really stuck.  Of course I don't have this problem in g++ under
cygwin,
> but I need to use Visual Studios for my project.  Thanks in advance.

> Kevin



Sat, 17 Dec 2005 03:03:27 GMT  
 valarray in .NET
Yes, thank you so much.  That did it!

Kevin


Quote:
> Put

> #define NOMINMAX

> before including any standard Windows headers such as <windows.h>. Some
> Windows header defines min and max as macros unless NOMINMAX is defined.
> This wreaks havoc with STL code.
> --
> With best wishes,
>     Igor Tandetnik

> "For every complex problem, there is a solution that is simple, neat,
> and wrong." H.L. Mencken



> > Hello, I'm not sure if this is the right newsgroup to post to, but I
> > couldn't find a microsoft group that is really active on this issue.

> > I'm getting problems when trying to compile code that uses valarrays.
> I'm
> > adding this code to an existing project.  But this problem doesn't
> exist if
> > I start a new project and have the code there.  So I'm thinking it's
> > something to do with the project compiler options.  So I check those
> between
> > the one that compiles and the one that doesn't, and they are
> identical.  For
> > example:

> > int main() {
> >     int a[] = {1,2,3};
> >     valarray<int> v(a, 3);
> >     return 0;
> > }

> > the compiler would give this error message:
> > c:\Program Files\Microsoft Visual Studio
> .NET\Vc7\include\valarray(309):
> > error C2059: syntax error : 'function-style cast'
> > and the code block that it finds offensive is:
> > L309--->_Ty min() const
> > { // return smallest of all elements
> >     _Ty _Min = _Myptr[0];
> >     for (size_t _Idx = 0; ++_Idx < size(); )
> >         if (_Myptr[_Idx] < _Min)
> >             _Min = _Myptr[_Idx];
> >     return (_Min);
> > }

> > I'm really stuck.  Of course I don't have this problem in g++ under
> cygwin,
> > but I need to use Visual Studios for my project.  Thanks in advance.

> > Kevin



Sat, 17 Dec 2005 14:37:24 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. valarray destruction

2. Namespace trubble using <valarray>

3. Problems with <valarray>

4. mfc and valarray

5. Bug in standard library <valarray>?

6. valarray question

7. std::valarray

8. valarray compile problem

9. valarray and c-Functions

10. <valarray> in MFC

11. Valarray : compiler error C4003

12. Valarray Trouble...

 

 
Powered by phpBB® Forum Software