RE: :min, std::max

  • As an example of the exact error I am getting;

    "error:expected unqualified-id before '(' token"

    then the error is pointing to the line
    "const streamsize __limit = std::min(__chunk, __bufavail):" in the file
    fstream.tcc

    there are 12 such errors, all relating to std::min and std::max.

    Carl

    -----Original Message-----
    Sent: Monday, October 24, 2005 5:40 PM
    To: <Xcode-users...>
    Subject: std::min, std::max

    I am trying to get my application that was compiling find under Xcode
    1.5 to compile in Xcode 2, but I keep getting errors, when compiling,
    relating to std::min( ) and std::max(). The files are containing the
    std::max/std::min calls are in the /usr/include/gcc/Darwin/4.0/ sub
    directories, such as /usr/include/gcc/Darwin/4.0/bits/fstream.tcc files
    and etc.

    I would have thought that a transfer direct compile from my 1.5 project
    would have been easy, but I was wrong.

    Any thoughts as to what I may need to include or bring into my Xcode 2.0
    project to get a clean compile?

    Thanks for any suggestions

    Carl
  • On Oct 24, 2005, at 2:53 PM, Carl Smith wrote:

    > As an example of the exact error I am getting;
    >
    >
    > “error:expected unqualified-id before ‘(‘ token”
    >
    >
    > then the error is pointing to the line
    >
    > “const streamsize __limit = std::min(__chunk, __bufavail):” in the
    > file fstream.tcc
    >
    >
    > there are 12 such errors, all relating to std::min and std::max.

    The usual cause for this is #defining min or max in some header file.

    Often people #define min(x,y) (x < y ? x : y) and that will be
    expanded in the definition of std:: min, which will blow up.

    Chris
  • Oct 25, 2005 kl. 12:14 AM skrev Chris Espinosa:

    >
    > On Oct 24, 2005, at 2:53 PM, Carl Smith wrote:
    >
    >> As an example of the exact error I am getting;
    >>
    >>
    >> “error:expected unqualified-id before ‘(‘ token”
    >>
    >>
    >> then the error is pointing to the line
    >>
    >> “const streamsize __limit = std::min(__chunk, __bufavail):” in the
    >> file fstream.tcc
    >>
    >>
    >> there are 12 such errors, all relating to std::min and std::max.
    >
    > The usual cause for this is #defining min or max in some header file.
    >
    > Often people #define min(x,y) (x < y ? x : y) and that will be
    > expanded in the definition of std:: min, which will blow up.
    >
    > Chris

    And of course this can be fixed by doing
    #undef min
    #undef max
    after including any C header.

    "Home is not where you are born, but where your heart finds peace" -
    Tommy Nordgren, "The dying old crone"
  • > And of course this can be fixed by doing
    > #undef min
    > #undef max
    > after including any C header.

    But sometimes I find this can cause problems if you're using precompiled
    headers -- you may need to fiddle with the ordering of your inclusions.
    It's a pain when you have C headers that define min and max.  My
    solution is usually to duplicate std::min and max but call it something
    slightly different, eg MaxValue()
  • On 25.10.2005, at 10:39, Paul Walmsley wrote:

    >
    >> And of course this can be fixed by doing
    >> #undef min
    >> #undef max
    >> after including any C header.
    >
    > But sometimes I find this can cause problems if you're using
    > precompiled headers -- you may need to fiddle with the ordering of
    > your inclusions.  It's a pain when you have C headers that define min
    > and max.  My solution is usually to duplicate std::min and max but
    > call it something slightly different, eg MaxValue()

    It's a pain when people carelessly define macros in public headers like
    min, max, I, _R, etc. etc.
    Also, it's careless when people using names like _R, like in the GNU
    standard lib.

    In a carbon produtc it's also a pain, getting ur source blown up when
    using the names check, verify and require.
    I want to blame Apple here!
    Really, i would appreciate it very much if Apple could get rid of these
    b.d. names in AssertMacros.h!

    Andreas

    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Xcode-users mailing list      (<Xcode-users...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/xcode-users/
    > <agrosam...>
    >
    > This email sent to <agrosam...>
    >
  • > Often people #define min(x,y) (x < y ? x : y) and that will be
    > expanded in the definition of std:: min, which will blow up.

    And that doesn't always work either; for example, then min(++j, k)
    expands to (++j < k ? ++j : k) which can return j incremented twice.
    --
    Prof. W. Douglas Maurer                Washington, DC 20052, USA
    Department of Computer Science        Tel. (1-202)994-5921
    The George Washington University      Fax  (1-202)994-4875
    NEW E-MAIL ADDRESS  <maurer...>
previous month october 2005 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today