3

why >?= and <?= don't work in VC++? but they work fine in gcc/g++ like: a>?=b; are they right usages?

lavinio
  • 23,931
  • 5
  • 55
  • 71
  • 3
    What does it do in gcc? Never saw this before. – Jim Buck Aug 05 '09 at 15:53
  • If these are deprecated as bdonlan says, I would expect g++ to print a warning when you use them. I recommend compiling with "-Wall" (warn all, i.e. show all warnings) and trying to write code that produces no warnings. Can someone confirm that g++ does print a warning when you use these operators? – Tyler Aug 05 '09 at 17:18
  • a>?=b <==> a=MIN(a,b) I use vim with g++ and compile with "-Wall", but I never see a warning. –  Aug 06 '09 at 13:49

2 Answers2

13

Those operators are non-standard and are deprecated in GCC. They are not even supported in G++ at all anymore. You should use std::min and std::max instead. Be sure to #define NOMINMAX to disable the window-specific macros that conflict with them.

bdonlan
  • 224,562
  • 31
  • 268
  • 324
7

Because those are the old GC++-specific extensions for minimum and maximum.

From 6. Extensions to the C++ Language:

The GNU compiler provides these extensions to the C++ language (and you can also use most of the C language extensions in your C++ programs). If you want to write code that checks whether these features are available, you can test for the GNU compiler the same way as for C programs: check for a predefined macro __GNUC__. You can also use __GNUG__ to test specifically for GNU C++ (see section 'Predefined Macros' in The GNU C Preprocessor).

Instead, you should use std::min and std::max.

lavinio
  • 23,931
  • 5
  • 55
  • 71