c++ - Template error only when windows.h is included
- Kramer (28/28) Mar 07 2005 I was trying to create a function template using a Windows function. Ho...
- Christof Meerwald (8/22) Mar 08 2005 I believe windows.h defines "max" as a macro (unless you compile with
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: #using namespace std; #template <typename T> #T max(T a, T b) #int main(int argc, char *argv[]) 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: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: #using namespace std; #template <typename T> #T max(T a, T b)I believe windows.h defines "max" as a macro (unless you compile with -DNOMINMAX) bye, Christof -- http://cmeerw.org mailto:cmeerw at web.de xmpp:cmeerw at cmeerw.org ...and what have you contributed to the Net?
Mar 08 2005