[Stk] Newbie Compile Errors

Ge Wang gewang@CS.Princeton.EDU
Mon, 18 Jul 2005 18:39:34 -0400


Hi Chris and all,

We have ran into similar problems before, though in cases where min and 
max appeared as functions in other header files on OS X, in conflict 
with STL headers - a combination of header file order arrangement and 
using ::min and ::max solved that problem.  This seems different.  
After doing a quick google search, we find the following:

"It's a known, long-standing bug in the compiler system's headers.  For 
some reason the manufacturer, in its infinite wisdom, chose to #define 
macros min() and max() in violation of the upper-case convention and so 
break any legitimate functions with those names, including those in the 
standard C++ library."

and

"This is a problem with windows.h, it includes the min() and max() 
macros which can easily screw over c++. Define NOMINMAX before 
windows.h is included and the problem goes away."

I think this may be what Immanuel was referring to.  One quick 
potential solution is to add NOMINMAX as a define in your project 
settings or makefile.  Another way is to manually add #define NOMINMAX 
before all windows.h includes (I grep and see 3 in include/ and 2 in 
src/).  These are still hacks (assuming NOMINMAX solves the problem), 
but are probably better than swapping out your valarray!

Hope this helps.

Best,
Ge!

On Jul 18, 2005, at 12:20 PM, Chris Share wrote:

> Hi,
>
> Yes, the example programs compile properly.
>
> I've managed to fix the problem with the following workaround:
>
> I've made a copy of valarray, commented out the offending code, and 
> then included this as a header. The program now compiles.
>
> I'd still like to know why the original code didn't work though.
>
> Cheers,
>
> Chris
>
>
> Gary P. Scavone wrote:
>> Hi Immanuel,
>> Stk doesn't use the max() and min() functions of valarray, so if  
>> there is a problem as you describe, it would have to be some internal 
>>  problem with VS2003.
>> I tested the last release in VS.net on XP before releasing and didn't 
>>  have this problem.
>> Chris, do the example programs compile for you?
>> Regards,
>> --gary
>> On Jul 18, 2005, at 11:52 AM, Immanuel Litzroth wrote:
>>> I looked at the output and this might be an issue where windows  
>>> defines
>>> max and min as macros, so call to std::max and std::min are  
>>> macroexpanded
>>> and problematic.
>>> Immanuel
>>>
>>> "Gary P. Scavone" <gary@music.mcgill.ca> writes:
>>>
>>>
>>>> Hi Chris,
>>>>
>>>> VS2003 seems to be having a problem with the valarray include
>>>> statement in Stk.h.  But my guess is that these errors might go away
>>>> if you compile for "release" instead of "debug".  I don't know why,
>>>> but there always seem to be problems with "debug" compiles with
>>>> Windoze.
>>>>
>>>> Just another note ... make sure to use the __LITTLE_ENDIAN__
>>>> preprocessor definition with WvIn.
>>>>
>>>> Regards,
>>>>
>>>> --gary
>>>>
>>>> On Jul 18, 2005, at 11:14 AM, Chris Share wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> I'd like to use STK for some research work that I'm currently 
>>>>> doing.
>>>>>
>>>>> I'm using Microsoft VS2003 on Windows XP.
>>>>>
>>>>> I thought that I'd start by writing a simple app that reads a .wav
>>>>> file however I'm getting errors while trying to use WvIn.h. The
>>>>> problem arises as soon as I include WnIn.h.
>>>>>
>>>>> Here are the errors that I'm getting:
>>>>>
>>>>> ------ Build started: Project: Waveguide_01, Configuration: Debug
>>>>> Win32 ------
>>>>>
>>>>> Compiling...
>>>>> Waveguide_01Dlg.cpp
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(314) : warning C4003: not enough actual parameters for
>>>>> macro 'min'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(323) : warning C4003: not enough actual parameters for
>>>>> macro 'max'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(314) : error C2059: syntax error : ')'
>>>>>         c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7
>>>>> \include\valarray(427) : see reference to class template
>>>>> instantiation 'std::valarray<_Ty>' being compiled
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(314) : error C2334: unexpected token(s) preceding ':';
>>>>> skipping apparent function body
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2143: syntax error : missing ')' before '}'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2143: syntax error : missing '}' before ')'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2059: syntax error : ')'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2143: syntax error : missing ';' before '}'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2238: unexpected token(s) preceding ';'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(323) : error C2146: syntax error : missing ';' before
>>>>> identifier '_Ty'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(314) : error C2059: syntax error : ')'
>>>>>         c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7
>>>>> \include\valarray(1124) : see reference to class template
>>>>> instantiation 'std::valarray<_Ty>' being compiled
>>>>>         with
>>>>>         [
>>>>>             _Ty=size_t
>>>>>         ]
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(314) : error C2334: unexpected token(s) preceding ':';
>>>>> skipping apparent function body
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2143: syntax error : missing ')' before '}'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2143: syntax error : missing '}' before ')'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2059: syntax error : ')'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(323) : error C2334: unexpected token(s) preceding ':';
>>>>> skipping apparent function body
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(330) : error C2143: syntax error : missing ')' before '}'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(330) : error C2143: syntax error : missing '}' before ')'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(330) : error C2059: syntax error : ')'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(330) : error C2143: syntax error : missing ';' before '}'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(330) : error C2238: unexpected token(s) preceding ';'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(332) : error C2146: syntax error : missing ';' before
>>>>> identifier 'valarray'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(314) : error C2059: syntax error : ')'
>>>>>         c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7
>>>>> \include\valarray(1333) : see reference to class template
>>>>> instantiation 'std::valarray<_Ty>' being compiled
>>>>>         with
>>>>>         [
>>>>>             _Ty=std::_Bool
>>>>>         ]
>>>>>         c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7
>>>>> \include\valarray(1335) : see reference to class template
>>>>> instantiation 'std::mask_array<_Ty>' being compiled
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(314) : error C2334: unexpected token(s) preceding ':';
>>>>> skipping apparent function body
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2143: syntax error : missing ')' before '}'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2143: syntax error : missing '}' before ')'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2059: syntax error : ')'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2143: syntax error : missing ';' before '}'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2238: unexpected token(s) preceding ';'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(323) : error C2146: syntax error : missing ';' before
>>>>> identifier '_Ty'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(314) : error C2059: syntax error : ')'
>>>>>         c:\Documents and Settings\Chris.LAPTOP\Desktop\Programming
>>>>> Work\Waveguide\Waveguide_01\stk\include\Stk.h(226) : see reference
>>>>> to class template instantiation 'std::valarray<_Ty>' being compiled
>>>>>         with
>>>>>         [
>>>>>             _Ty=StkFloat
>>>>>         ]
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(314) : error C2334: unexpected token(s) preceding ':';
>>>>> skipping apparent function body
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2143: syntax error : missing ')' before '}'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2143: syntax error : missing '}' before ')'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(321) : error C2059: syntax error : ')'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(323) : error C2334: unexpected token(s) preceding ':';
>>>>> skipping apparent function body
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(330) : error C2143: syntax error : missing ')' before '}'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(330) : error C2143: syntax error : missing '}' before ')'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(330) : error C2059: syntax error : ')'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(330) : error C2143: syntax error : missing ';' before '}'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(330) : error C2238: unexpected token(s) preceding ';'
>>>>> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
>>>>> \valarray(332) : error C2146: syntax error : missing ';' before
>>>>> identifier 'valarray'
>>>>>
>>>>> Build log was saved at "file://c:\Documents and Settings
>>>>> \Chris.LAPTOP\Desktop\Programming Work\Waveguide\Waveguide_01\Debug
>>>>> \BuildLog.htm"
>>>>> Waveguide_01 - 40 error(s), 2 warning(s)
>>>>>
>>>>>
>>>>> ---------------------- Done ----------------------
>>>>>
>>>>>     Build: 0 succeeded, 1 failed, 0 skipped
>>>>>
>>>>>
>>>>> Any idea what I'm doing wrong?
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Chris
>>>>>
>>>>> _______________________________________________
>>>>> Stk mailing list
>>>>> Stk@ccrma.stanford.edu
>>>>> http://ccrma-mail.stanford.edu/mailman/listinfo/stk
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Stk mailing list
>>>> Stk@ccrma.stanford.edu
>>>> http://ccrma-mail.stanford.edu/mailman/listinfo/stk
>>>
>>>
>
> _______________________________________________
> Stk mailing list
> Stk@ccrma.stanford.edu
> http://ccrma-mail.stanford.edu/mailman/listinfo/stk