standards-compliance

__USE_FILE_OFFSET64 vs. _FILE_OFFSET_BITS=64

这一生的挚爱 提交于 2019-12-02 20:27:52
I am trying to maintain code that compiles on lots of different systems. I've seen a dozen different ways of asking for lseek that takes 64-bits. Some systems use lseek64 , some use lseeko , some require that you define _FILE_OFFSET_BITS=64 , and now I just found a new one that requires that you define __USE_FILE_OFFSET64 . Is there any standard to all of this? Sergey Vlasov There are getconf values in IEEE Std 1003.1-2004 (and a newer set in IEEE Std 1003.1-2008 ; see also the EXAMPLES section in those documents). Actual compiler options (which might not even be defines) are not specified.

Are there any compilers that IGNORE C++ standard about default inline functions?

跟風遠走 提交于 2019-12-02 12:00:06
问题 C++ ISO standard says, that: "A function defined within a class definition is an inline function." Are there any compilers that IGNORE this rule? (please, do not mistake inline with inlineD - my question is if there is a compiler, that wont put there that inline suggestion that it should) 回答1: You seem to be misunderstanding what "inline" means. It doesn't mean functions will automatically be inlined; according to 7.1.2-2 it indicates that inline substitution is to be preferred. Therefore,

Are there any compilers that IGNORE C++ standard about default inline functions?

本秂侑毒 提交于 2019-12-02 05:43:11
C++ ISO standard says, that: "A function defined within a class definition is an inline function." Are there any compilers that IGNORE this rule? (please, do not mistake inline with inlineD - my question is if there is a compiler, that wont put there that inline suggestion that it should) You seem to be misunderstanding what "inline" means. It doesn't mean functions will automatically be inlined; according to 7.1.2-2 it indicates that inline substitution is to be preferred. Therefore, you can't tell whether a function is labeled inline or not from the code, since the compiler is free to decide

Swift protocol conformance requirements for subtypes [duplicate]

╄→гoц情女王★ 提交于 2019-12-02 03:43:30
问题 This question already has answers here : Why can't a get-only property requirement in a protocol be satisfied by a property which conforms? (2 answers) Closed last year . (if someone can suggest a better title, please do) The following code does not compile with an error Type 'ObserverClass' does not conform to protocol 'Observer' , and compiler suggests a fix by declaring var object: ObservedObject . class ObservedObject {} class ObservedObjectSubclass: ObservedObject {} protocol Observer {

Swift protocol conformance requirements for subtypes [duplicate]

大憨熊 提交于 2019-12-02 03:07:29
This question already has an answer here: Why can't a get-only property requirement in a protocol be satisfied by a property which conforms? 1 answer (if someone can suggest a better title, please do) The following code does not compile with an error Type 'ObserverClass' does not conform to protocol 'Observer' , and compiler suggests a fix by declaring var object: ObservedObject . class ObservedObject {} class ObservedObjectSubclass: ObservedObject {} protocol Observer { var object: ObservedObject { get } } class ObserverClass: Observer { // Type 'ObserverClass' does not conform to protocol

Difference in display between HTML and XHTML

我与影子孤独终老i 提交于 2019-12-01 20:22:18
I thought XHTML documents were supposed to be displayed with exactly the same standards compliance mode as "strict" HTML documents. However, there is a difference in how they display pre elements: in HTML documents, if the <pre> start tag is followed by a LF (or CRLF), this is ignored. Not so in XHTML. Example: a HTML file and a XHTML file that have the same content, but are rendered differently. (Or if you think it's cheating to give a HTML file and a XHTML file exactly the same content, including DOCTYPE, here are two files that follow more classic rules: HTML 4.01 strict and XHTML 1.0

delete[] supplied a modified new-ed pointer. Undefined Behaviour?

时光毁灭记忆、已成空白 提交于 2019-12-01 18:16:59
问题 I saw some code as below during a peer-code-review session: char *s = new char[3]; *s++ = 'a'; *s++ = 'b'; *s++='\0'; delete []s; // this may or may not crash on some or any day !! Firstly, I know that in Standard C++, pointing to one-past the array-size is O.K. though accessing it results in undefined behaviour. So I believe the last line *s++='\0' is fine. But if I recall correctly, the C++ standard mandates that delete should be supplied the same pointer that new returned. This I believe

delete[] supplied a modified new-ed pointer. Undefined Behaviour?

放肆的年华 提交于 2019-12-01 17:51:45
I saw some code as below during a peer-code-review session: char *s = new char[3]; *s++ = 'a'; *s++ = 'b'; *s++='\0'; delete []s; // this may or may not crash on some or any day !! Firstly, I know that in Standard C++, pointing to one-past the array-size is O.K. though accessing it results in undefined behaviour. So I believe the last line *s++='\0' is fine. But if I recall correctly, the C++ standard mandates that delete should be supplied the same pointer that new returned. This I believe means that the returned pointer must not be tampered-with. I guess it is because new might keep some

Non-ASCII characters in C

↘锁芯ラ 提交于 2019-12-01 17:47:06
I was looking at google go's runtime source code (at https://go.googlecode.com/hg/src/pkg/runtime/ ), and it seems they use a special character for their function names, · . (Look for example at https://go.googlecode.com/hg/src/pkg/runtime/cgocall.c ). Is this accepted across major compilers? It's not ANSI C, is it? Or is it just some macro magic? Thank you! C90 doesn't allow additional character in identifier (over those in the basic characters set), C99 do (both with the universal character syntax -- \uXXXX and \UXXXXXXXX -- and an implementation defined set of other characters). 6.4.2.1/1

__func__ C++11 function's local predefined variable, won't compile

一世执手 提交于 2019-12-01 15:56:40
The __func__ C++11 local predefined variable of a function does not compile in Visual Studio 2012 Professional (with Update 1 installed) with the default built-in Visual Studio 2012 (v110) compiler or the November 2012 CTP (v120_CTP_Nov2012) compiler. However, the editor does not complain with any red squiggly underline under __func__ . __func__ is supposed to give the name of its containing function, in this case foo , but this neither compiles nor make the editor complain: #include <iostream> using namespace std; void foo() { cout << __func__ << endl; return; } int main() { foo(); return 0;