What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 130 Stack Exchange communities.

Challenge: Programmatically detect whether code is compiled with C++03 or C++0x

I am frustrated that this Stack Overflow question, that is about c++ is migrated to Code Golf. This isn't Code Golf. Just because the question is phrased in the form of a challenge, doesn't mean anything.

share|improve this question
9  
Your question is the second highest voted right now on codegolf, and you didn't even have to open an account there. Maybe you should be more proud of your achievements and think about the migration in a more positive light :) –  Frédéric Hamidi Jun 26 '11 at 22:57
3  
Frédéric: The three highest-voted questions on CGSE are migrated from SO and achieved the majority of their votes on SO, not on CGSE. In a way you cannot measure them against questions that originated on CGSE since SO has way more users and thus voters. In my personal opinion many questions that were migrated from SO do not really belong on CGSE. They might be challenges, puzzles or similar but we have a different culture than SO, different rules as well. And mods that migrate questions are often not even members of CGSE, let alone participate there to know what the site is like. –  Joey Jun 27 '11 at 23:33

3 Answers 3

up vote 11 down vote accepted

Quoting the bottom of your question:

Challenge: Write a function

bool isCpp0x() {...}

without the use of preprocessor that will return true if compiled with a compliant C++0x compiler and false if with a plain old C++03 compiler. I don't know for sure that this is possible. Go! :)

Per http://codegolf.stackexchange.com/faq

As this site's title suggests, Programming Puzzles & Code Golf is for programming puzzles and code golf, anywhere in skill from beginner to expert.

edit: based on Jerry Coffin's excellent proposed edit, I reinstated it on SO. lesson to be learned: don't add bogus "challenges" to your questions to "spice them up". Just ask your question in a simple, straightforward manner.

share|improve this answer
1  
"All questions on this site should have ... An objective primary winning criterion, so that it is possible to indisputably decide which entry should win.". –  Johannes Schaub - litb Jun 27 '11 at 20:58
1  
The part you quoted is more or less equivalent to "Is it possible to write a function that returns true when compiled with C++0x and false with C++03? Please give examples, without trivial use of #if". One should not be confused by the words "Go!" and "Challenge: Write a function ...". –  Johannes Schaub - litb Jun 27 '11 at 21:01
    
@johannes so shortest solution wins, then. (where shortest is shorthand for "simplest", usually) –  Jeff Atwood Jun 27 '11 at 22:18
1  
Jeff: It wasn't written as a Code Golf so shortest solution doesn't really apply. Imho, as it stands the question is a poor one for CGSE (needs major rewriting and possibly not along the intent of the original author) and with only minor rewriting it would have been fine on SO. So the sole criterion was the word »challenge«? –  Joey Jun 27 '11 at 23:39
1  
@joey ok, I just decided to delete the question from both sites since it is a bad fit in both places. But then I saw Jerry Coffin's proposed edit, so I just made that so. –  Jeff Atwood Jun 27 '11 at 23:42

The site's name isn't Code Golf, it's Programming Puzzles and Code Golf. Code challenges are on-topic there and not on-topic on Stack Overflow.

You say,

Just because the the question is phrased in a form of a challenge doesn't mean anything.

But that means a whole lot here: how a question is presented determines how it is answered. If you have a practical problem you need help with, ask about that in your question: don't present it as a code challenge and hope people read between the lines.

share|improve this answer
    
So is stackoverflow.com/questions/1201593/… and stackoverflow.com/questions/304088/is-c-code-still-considered-c and such offtopic on SO and ontopic on "programming puzzles and code golf?". Note: Both questions are very similar to the question being discussed. Asking for "is X a subset/superset of Y" implicitly asks for examples, hence is also a "code challenge" and offtopic on SO? that doesn't make sense. –  Johannes Schaub - litb Jun 27 '11 at 20:56
1  
@johannes I now feel this question is a bad fit on both sites, so I am deleting it everywhere. But then I saw Jerry Coffin's proposed edit, so I just made that so, as I feel it is a better solution. This question was SPECTACULARLY poorly written. –  Jeff Atwood Jun 27 '11 at 23:44

Jerry Coffin gave the best reason for keeping your question on SO, however, it would require you to edit your question significantly:

@sixlettervariables: while it's certainly open to argument that the phrasing could be better, it seems to me that the fundamental notion of the question (what differences, if any, between C++03 and C++0x can be detected at run-time?) is perfectly legitimate. Given that the code has to compile and execute in both, it could also be phrased as being about the breaking changes in C++0x. That seems to me like a perfectly legitimate question to ask as well. – Jerry Coffin 4 hours ago

I certainly would not have voted to close that question.

share|improve this answer
    
I went with that solution for now, since it seems not a good fit in either place. Lesson: don't add unnecessary BS to your questions.. –  Jeff Atwood Jun 27 '11 at 23:54
    
@Jeff: looks good. I've gone and removed my noise comments now that it has been substantially edited. –  user7116 Jun 28 '11 at 0:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .