?" in gcc Does anyone know about >? operator? I have a macro with the definition below that causes an e...">

Does anyone know this mysterious operator ">?" in gcc

Does anyone know about >? operator? I have a macro with the definition below that causes an error, but I still have not seen such an operator:

 #define MAX_SIZEOF2(a,b) (sizeof(a) >? sizeof(b)) 
+7
c ++ c gcc
source share
3 answers

Minimum and maximum operators are the deprecated gcc extension :

The minimum and maximum g ++ operators (' <? And' >? ) And their composite forms (' >?= ) And <?= ) <?= deprecated and are now removed from g ++. Code using these operators must be modified to use std::min and std::max instead.

Here is what is written in the old documentation :

It is very convenient to have statements that return a β€œminimum” or β€œmaximum” of two arguments. In GNU C ++ (but not in GNU C),

a <? b

- this is the minimum returning smaller numeric values ​​a and b;

a >? b

- the maximum value that returns a larger number of numeric values ​​a and b.

This had the advantage of allowing you to avoid macros that might have problems with side effects if they weren't used carefully.

+5
source share

I assume it was removed from GCC 4.2

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

From the manual

The minimum and maximum g ++ operators (' <? And' >? ) And their composite forms (' >?= ) And' <?= ) <?= deprecated and are now removed from g ++. Code using these operators must be modified to use std::min and std::max .

EDIT:

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

+4
source share

This is an outdated non-standard operator that gives maximum of its operands. GCC no longer supports it.

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

+3
source share

All Articles