8

Does anyone know about >? operator? I have a macro with below definition which is throwing error, but I have never seen such an operator till now:

#define MAX_SIZEOF2(a,b)           (sizeof(a) >? sizeof(b))
Shafik Yaghmour
  • 154,301
  • 39
  • 440
  • 740
vimal prathap
  • 411
  • 7
  • 17

3 Answers3

6

The minimum and maximum operators are a deprecated gcc extension:

The G++ minimum and maximum operators (‘<?’ and ‘>?’) and their compound forms (‘>?=’) and ‘<?=’) have been deprecated and are now removed from G++. Code using these operators should be modified to use std::min and std::max instead.

Here is what the older documentation says:

It is very convenient to have operators which return the “minimum” or the “maximum” of two arguments. In GNU C++ (but not in GNU C),

a <? b

is the minimum, returning the smaller of the numeric values a and b;

a >? b

is the maximum, returning the larger of the numeric values a and b.

This had the advantage that it allowed you to avoid macros which could have issues with side-effects if they were not used carefully.

Shafik Yaghmour
  • 154,301
  • 39
  • 440
  • 740
5

I guess it has been removed from GCC version 4.2

The equivalent of a >?= b is a = max(a,b);

From the manual

The G++ minimum and maximum operators (‘<?’ and ‘>?’) and their compound forms (‘>?=’) and ‘<?=’) have been deprecated and are now removed from G++. Code using these operators should be modified to use std::min and std::max instead.

EDIT:

From your comments, you need to add #include <algorithm> to use the std::max and std::min. You can also check this for reference.

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
  • Is there any flag in GCC 4.8, so that i can enable >? . Because when i use std::max, i am getting error that max is not part of std or is there any alternate solution exist? – vimal prathap May 06 '15 at 13:41
  • @vimalprathap:- Try to add `#include `. For reference you can check http://en.cppreference.com/w/cpp/algorithm/max – Rahul Tripathi May 06 '15 at 13:49
3

It's a deprecated non-standard operator which gives the maximum of its operands. GCC no longer supports it.

In C++, this is equivalent to std::max(sizeof(a), sizeof(b)).

Mike Seymour
  • 249,747
  • 28
  • 448
  • 644