Thread: warning C4003: not enough actual parameters for macro 'min'

  1. #1
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    warning C4003: not enough actual parameters for macro 'min'

    E:\PROGRAMMING\CPP\MLIBRARY\MValue.h(56) : warning C4003: not enough actual parameters for macro 'min'
    This is the error I get at the spot I'm using:
    Code:
    InitialMin = std::numeric_limits<int>::min();
    It seems like another min() function/macro exists. After some research on this forum I found that this could be solved by undefining min before including <limits>. However that solution is really ugly. Why does this collision occur anyway? I'm using the full std:: notation, and the whole point of using namespaces is to avoid these collisions, right?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793

    Re: warning C4003: not enough actual parameters for macro 'min'

    Originally posted by Magos
    This is the error I get at the spot I'm using:
    Code:
    InitialMin = std::numeric_limits<int>::min();
    It seems like another min() function/macro exists. After some research on this forum I found that this could be solved by undefining min before including <limits>. However that solution is really ugly. Why does this collision occur anyway? I'm using the full std:: notation, and the whole point of using namespaces is to avoid these collisions, right?
    I think it's because macros are expanded by the preprocessor before any of the C++ name resolution takes place. That's why they are discouraged over using inline functions in C++.

    I had this problem with a version of Codewarrior whenever I used windows.h and certian parts of the stl. The #undef solution worked ok for me

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    I guess this is one of the reasons Stroustrup advertises non-usage of macros .
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 14
    Last Post: 07-14-2009, 08:16 AM
  2. pointers, structures, and malloc
    By lugnut in forum C Programming
    Replies: 24
    Last Post: 10-09-2008, 04:52 PM
  3. warning C4013...errrrrr!
    By IndioDoido in forum C Programming
    Replies: 27
    Last Post: 03-21-2008, 02:02 AM
  4. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM