Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does anyone know this mysterious operator ">?" in GCC [duplicate]

Tags:

c++

c

gcc

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))
like image 969
vimal prathap Avatar asked May 06 '15 11:05

vimal prathap


3 Answers

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.

like image 102
Shafik Yaghmour Avatar answered Nov 15 '22 12:11

Shafik Yaghmour


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.

like image 26
Rahul Tripathi Avatar answered Nov 15 '22 12:11

Rahul Tripathi


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)).

like image 3
Mike Seymour Avatar answered Nov 15 '22 13:11

Mike Seymour