standards

strcmp() and signed / unsigned chars

徘徊边缘 提交于 2019-12-19 05:08:44
问题 I am confused by strcmp(), or rather, how it is defined by the standard. Consider comparing two strings where one contains characters outside the ASCII-7 range (0-127). The C standard defines: int strcmp(const char *s1, const char *s2); The strcmp function compares the string pointed to by s1 to the string pointed to by s2. The strcmp function returns an integer greater than, equal to, or less than zero, accordingly as the string pointed to by s1 is greater than, equal to, or less than the

Why will std::rel_ops::operators be deprecated in C++20?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 05:06:38
问题 According to cppreference.com, std::rel_ops::operator!=,>,<=,>= will be deprecated in C++20. What's the rationale behind? 回答1: In C++20, you get three-way comparison (operator <=> ), which automatically "generates" default comparisons if provided: struct A { // You only need to implement a single operator. std::strong_ordering operator<=>(const A&) const; }; // Compiler generates all 6 relational operators A to1, to2; if (to1 == to2) { /* ... */ } // ok if (to1 <= to2) { /* ... */ } // ok,

Are brackets in the WHERE clause standard sql

二次信任 提交于 2019-12-19 02:39:33
问题 The course that I am currently doing uses brackets in its WHERE clauses like so: SELECT bar FROM Foo WHERE (CurrentState = 'happy'); Is this standard sql ? If not then why use them? Doesn't seem to be used in the Date & Darwen book I have. EDIT Just to clarify - I'm referring to 1992 sql standards 回答1: Yes. You can use parenthesis to bind components of where clauses. This isn't necessary in your example, but if you had multiple and and or components, you might need parenthesis to either

Python: How to read stdout of subprocess in a nonblocking way

微笑、不失礼 提交于 2019-12-18 16:51:34
问题 I am trying to make a simple python script that starts a subprocess and monitors its standard output. Here is a snippet from the code: process = subprocess.Popen([path_to_exe, os.path.join(temp_dir,temp_file)], stdout=subprocess.PIPE) while True: output=process.stdout.readline() print "test" The problem is that the script hangs on output=process.stdout.readline() and that the line print "test" only executes after the subprocess is terminated. Is there a way to read standard output and print

What was Wrong with void main()?

拈花ヽ惹草 提交于 2019-12-18 14:18:09
问题 Why has setting the entry point's return type to void in C++ always been discouraged, and was later removed by the standard and is prohibited by modern compilers? Why is it considered bad practice? Now, as I understand C# and Java both allow the entry point's return type to be void i.e static void main(String[] args) /* Java */ static void Main(string[] args) /* C# */ And C# and Java programmers do not consider it bad practice, they use it often in fact. Other languages which are (only

Are there any differences between ANSI C and ISO C?

≡放荡痞女 提交于 2019-12-18 13:12:05
问题 I understand that there is both an ANSI standard and an ISO standard for C. Are there any differences between these two standards? If so, what are they? And if there is not a difference then what's the point of having two standards? 回答1: In 1990, the ANSI C standard (with a few minor modifications) was adopted by the International Organization for Standardization as ISO/IEC 9899:1990. This version is sometimes called C90. Therefore, the terms "C89" and "C90" refer to essentially the same

Integer division overflows

不想你离开。 提交于 2019-12-18 13:05:38
问题 The Problem I have been thinking about integer (type int) overflows, and it occurs to me that division could overflow. Example : On my current platform, I have INT_MIN == -INT_MAX - 1 and thus INT_MIN < -INT_MAX and thus INT_MIN / -1 > -INT_MAX / -1 and thus INT_MIN / -1 > INT_MAX. Hence, the division ( INT_MIN / -1 ) does overflow. The Questions So, I have two questions: What (cross-platform) C code could one write in order to prevent division overflows (for type (signed) int)? What

Why does the .tagName DOM property return an uppercase value?

别来无恙 提交于 2019-12-18 11:46:06
问题 For example, if we have <html> <head> <title>FooBar</title> </head> <body></body> </html> If we do document.getElementByTagName("title").TagName , then we will have TITLE (uppercase). While the html standards recommends writing html tags in lowercase. I know there is no relationship between both, but this still doesn't make sense. Is there any reason that DOM should return tag names in uppercase? 回答1: Technically, this is mandated in DOM Level 1: The HTML DOM returns the tagName of an HTML

In an ISO 8601 date, is the T character mandatory?

跟風遠走 提交于 2019-12-18 11:45:17
问题 I'm wondering if the following date is ISO8601 compliant : 2012-03-02 14:57:05.456+0500 (for sure, 2012-03-02T14:57:05.456+0500 is compliant, but not that much human readable !) IOW, is the T between date and time mandatory ? 回答1: It's required unless the "partners in information interchange" agree to omit it. Quoting the ISO 8601 standard, section 4.3.2: The character [T] shall be used as time designator to indicate the start of the representation of the time of day component in these

Does standard C++11 guarantee that memory_order_seq_cst prevents StoreLoad reordering of non-atomic around an atomic?

我的梦境 提交于 2019-12-18 11:15:40
问题 Does standard C++11 guarantee that memory_order_seq_cst prevents StoreLoad reordering around an atomic operation for non-atomic memory accesses? As known, there are 6 std::memory_order s in C++11, and its specifies how regular, non-atomic memory accesses are to be ordered around an atomic operation - Working Draft, Standard for Programming Language C++ 2016-07-12: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/n4606.pdf § 29.3 Order and consistency § 29.3 / 1 The enumeration memory