tags:

views:

184

answers:

3

I ran across the following lines of C++ code in a file (non-contiguous lines) that gcc 4.2.1 won't accept:

int frame = blk <? mBlkCnt-1;
mInsCnt = blk <? mBlkCnt;
mInsCnt = mInsCnt+1 <? mBlkCnt;
const int to_read = (mFileSz-byte_off) <? mBlkSz;

Both <? and >? are used in various places in the code. They appear to be a shorthand for assigning the smaller (or larger) of two values, but I've never seen this operator combination. Any ideas on what this is?

+2  A: 

It's not a C++ operator, that's for sure. It almost resembles a digraph, but certainly not a valid one. In any case, a digraph, if supported, would just result in punctuation, not a whole new operator.

So, in answer to your question, perhaps this file needs to be preprocessed by some preprocessor that converts it to valid C++.

Michael Goldshteyn
examples of digraphs are <% and %> which represent { and } respectively
Armen Tsirunyan
+18  A: 

They're called the min and max operators and were language extensions in earlier versions of gcc.

They are no longer supported.

sepp2k
Refs: http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_5.html#SEC107 http://gcc.gnu.org/onlinedocs/gcc-4.5.1/gcc/Deprecated-Features.html#Deprecated-Features
Potatoswatter
+1 for enlightening us but I'm glad they're gone from GCC. I'd hate to see C++ suffer from what happened to Java when Microsoft did their Visual J++ extensions.
Amardeep
That's a funny link. "However, writing MIN and MAX as macros also forces you to use function-call notation for a fundamental arithmetic operation." Min and max are "fundamental arithmetic operations"?
calmh
The MIN and MAX macros in the gcc 3.3.6 docs linked above look wrong #define MIN(X,Y) ((X) < (Y) ? : (X) : (Y)) -- extra colon
@User: The author probably slipped up and used another extension, the binary `?:` operator. See http://gcc.gnu.org/onlinedocs/gcc-4.5.1/gcc/Conditionals.html - this one isn't deprecated, but rather works like `||` does in Python and other languages.
Potatoswatter
@Potatoswatter: Thanks. Learning a lot about extensions today...
I believe that the extensions in C (http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html) also apply to C++.
Gabe
A: 

Interesting question.. A little off-topic, but still that much interesting and strange - have you ever known, that there were special symbols :> and <: ? Years ago, some keyboards haven't have the keys "[" and "]", so ":>" used to mean "]" and "<:" used to mean "[". Interesting, huh?

Kiril Kirov