Question

I observed that there was at some point a <? and >? operator in GCC. How can I use these under GCC 4.5? Have they been removed, and if so, when?

Offset block_count = (cpfs->geo.block_size - block_offset) <? count;
cpfs.c:473: error: expected expression before ‘?’ token
Was it helpful?

Solution

Recent manuals say:

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.

A quick search of the past documents seems to indicate that they were removed around version 4.0 (3.4.6 includes them, 4.0.4 does not).

OTHER TIPS

Earlier iterations of g++ (not the C compiler) used these operators for giving you the minimum or maximum values but they've long been deprecated in favour of std::min and std::max.

Basically, they equated to (but without the possibility of double evaluation of a or b):

a <? b       -->       (a < b) ? a : b
a >? b       -->       (a > b) ? a : b

In terms of replacing them (and you really should replace them), you can use something like:

Offset block_count = cpfs->geo.block_size - block_offset;
if (block_count > count) block_count = count;

or equivalents using std::min.

I'm not a big fan of using C/C++ "extensions" (especially ones that have been deprecated and/or removed) since they tie me to a specific implementation of the language.

You should never use a non-standard extension where a perfectly adequate standard method is available.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top