Thread: Problem with macros and templates

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    3
    Quote Originally Posted by Elysia View Post
    Never create macros with lower-case names, especially for common names like min and max!
    That said, the solution would be, like whiteflags said, to make them template functions. They obey scope, at least, and don't give incomprehensible syntax errors everywhere.
    I think the macro generates templated min/max functions, so in the end there are no lowercase macros.

    Anyway, I have a theory on where the problem might be.
    PREVIOUSLY: I think the problem might be that one of the projects include <algorithm>, which defines templated min/max functions.
    EDIT:When I look up min() or max() i VS, they are defined as macros in WinDef.h. The problem is that no file in the project seems to include WinDef.h, at least not directly. Can this be solved with namespaces somehow?
    Last edited by Nickedname; 10-25-2011 at 12:28 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with templates
    By manasij7479 in forum C++ Programming
    Replies: 7
    Last Post: 10-05-2011, 07:08 PM
  2. problem with program number divisible by 10? using macros
    By MarjunC in forum C++ Programming
    Replies: 5
    Last Post: 06-23-2010, 05:43 AM
  3. Problem with macros..
    By sanddune008 in forum C Programming
    Replies: 4
    Last Post: 07-07-2009, 02:00 AM
  4. Macros inside of macros
    By Chewie8 in forum C Programming
    Replies: 2
    Last Post: 02-24-2008, 03:51 AM
  5. Templates and Macros plus more...
    By Monkeymagic in forum C++ Programming
    Replies: 8
    Last Post: 01-20-2007, 05:53 PM