![]() |
Can someone please tell me what this operator does?
I inherited soem weird code that makes no sense to me :S The following
line compiles under the gnu c++ compiler int requiredLength = requestedLength >? 32; but the windows c++ compiler rejects the >? operator and I have no idea what it does, nor can I find any mention of this when I google for the operator. The complete code section has been modified with #ifdef to get it to work via the windows c++ compiler #ifdef WIN32_COMPILER int bar = foo; if (bar < 32) { bar = 32; } #else int bar = foo >? 32; #endif So the >? operator is expanded in the windows code to a check for bar less than 32 and if true assign 32 to bar. Yet the condensed gnu version of the code uses a greater than operator and presumably the ternary operator :? |
Re: Can someone please tell me what this operator does?
Pep wroteÂ*:
> I inherited soem weird code that makes no sense to me :S The following > line compiles under the gnu c++ compiler > > int requiredLength = requestedLength >? 32; > > but the windows c++ compiler rejects the >? operator and I have no idea > what it does, nor can I find any mention of this when I google for the > operator. > > The complete code section has been modified with #ifdef to get it to > work via the windows c++ compiler > > > #ifdef WIN32_COMPILER > int bar = foo; > > if (bar < 32) > { > bar = 32; > } > #else > int bar = foo >? 32; > #endif > > So the >? operator is expanded in the windows code to a check for bar > less than 32 and if true assign 32 to bar. Yet the condensed gnu version > of the code uses a greater than operator and presumably the ternary > operator :? What version of gcc are you using again? Got this with gcc 4.2.4, 4.3.4, 4.5.1 : http://ideone.com/1xNEK -- perl -e 's;;{]``*%)}`_^[&)/#%(`&;;\ y;%^)([]/*#&`_{};.\100acghiklmopsz;;print' |
Re: Can someone please tell me what this operator does?
Lucien Coffe wroteÂ*:
> Pep wroteÂ*: > >> I inherited soem weird code that makes no sense to me :S The following >> line compiles under the gnu c++ compiler >> >> int requiredLength = requestedLength >? 32; >> >> but the windows c++ compiler rejects the >? operator and I have no idea >> what it does, nor can I find any mention of this when I google for the >> operator. >> >> The complete code section has been modified with #ifdef to get it to >> work via the windows c++ compiler >> >> >> #ifdef WIN32_COMPILER >> int bar = foo; >> >> if (bar < 32) >> { >> bar = 32; >> } >> #else >> int bar = foo >? 32; >> #endif >> >> So the >? operator is expanded in the windows code to a check for bar >> less than 32 and if true assign 32 to bar. Yet the condensed gnu >> version of the code uses a greater than operator and presumably the >> ternary operator :? > > What version of gcc are you using again? Got this with gcc 4.2.4, 4.3.4, > 4.5.1 : http://ideone.com/1xNEK They are called "minimum/maximum operators", and are deprtecated. http://gcc.gnu.org/onlinedocs/gcc-3...._6.html#SEC116 -- perl -e 's;;{]``*%)}`_^[&)/#%(`&;;\ y;%^)([]/*#&`_{};.\100acghiklmopsz;;print' |
Re: Can someone please tell me what this operator does?
On Wed, 2011-09-21, Lucien Coffe wrote:
> Lucien Coffe wrote*: > >> Pep wrote*: >> >>> I inherited soem weird code that makes no sense to me :S The following >>> line compiles under the gnu c++ compiler >>> >>> int requiredLength = requestedLength >? 32; .... > > They are called "minimum/maximum operators", and are deprtecated. > > http://gcc.gnu.org/onlinedocs/gcc-3...._6.html#SEC116 And they don't work in g++ either, if you tell it to compile standard C++. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
Re: Can someone please tell me what this operator does?
On Sep 21, 1:48*pm, Pep <pepaltavi...@yahoo.co.uk> wrote:
> I inherited soem weird code that makes no sense to me :S The following > line compiles under the gnu c++ compiler > > int requiredLength = requestedLength >? 32; It wouldn't compile under g++ 4.5.3 > The complete code section has been modified with #ifdef to get it to > work via the windows c++ compiler > > #ifdef WIN32_COMPILER > * * * * int bar = foo; > > * * * * if (bar < 32) > * * * * { > * * * * * * * * bar = 32; > * * * * } > #else > * * * * int bar = foo >? 32; > #endif > Why would you do that? Why not to use a standard, portable std::max? It does not have any side effects, like MAX macro. If, for some reason, you can't (or don't want to) use STL, just change it to int requiredLength = requestedLength > 32 ? requestedLength : 32; I strongly suggest to avoid using platform/compiler dependent code for such simple things. |
Re: Can someone please tell me what this operator does?
Pep wrote:
> I inherited soem weird code that makes no sense to me :S The following > line compiles under the gnu c++ compiler > > int requiredLength = requestedLength >? 32; > > but the windows c++ compiler rejects the >? operator and I have no > idea what it does, nor can I find any mention of this when I google > for the operator. > > The complete code section has been modified with #ifdef to get it to > work via the windows c++ compiler > > > #ifdef WIN32_COMPILER > int bar = foo; > > if (bar < 32) > { > bar = 32; > } > #else > int bar = foo >? 32; > #endif > > So the >? operator is expanded in the windows code to a check for bar > less than 32 and if true assign 32 to bar. Yet the condensed gnu > version of the code uses a greater than operator and presumably the > ternary operator :? It's GNU's maximum operator. See: http://gcc.gnu.org/onlinedocs/gcc-2...._5.html#SEC107 Just strip every instance of these funny operators out of your code and replace them with decent, standard alterantives such as std::max, as Yakov Gerlovin suggested. Rui Maciel |
| All times are GMT. The time now is 09:02 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.