|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - Template error only when windows.h is included
I was trying to create a function template using a Windows function. However I
kept getting an error I didn't know how to resolve. This example is contrived,
but it illustrates the error. I know DigitalMars didn't write windows.h, but I
just started using DMC, so I was hoping someone has run across this before and
knows of a solution.
Here's the code:
##include <windows.h>
##include <iostream>
#using namespace std;
#template <typename T>
#T max(T a, T b)
#{
# return a > b ? a : b ;
#}
#int main(int argc, char *argv[])
#{
# cout << max(10, 15);
# return 0;
#}
When I compile using the compile command: dmc Test20050307_1.cpp
-Ic:\dm\stlport\stlport
I get this error: Test20050307_1.cpp(7) : Error: closing ')' of '( declarator )'
expected
--- errorlevel 1
However, if you comment out windows.h, using the compile command above, it
compiles clean.
I'm just really confused, because the code looks correct to me.
-Kramer
Mar 07 2005
On Mon, 7 Mar 2005 17:18:21 +0000 (UTC), Kramer wrote: Mar 08 2005
|