standards

Is it okay to use “and”, “or” etc. instead of “&&”, “||”?

不打扰是莪最后的温柔 提交于 2020-01-10 02:20:07
问题 I'm used to the and and or keywords in C++. I've always used them and typing them is fast and comfortable for me. Once I've heard that these aliases are non-standard and may not work on all compilers. But I'm not sure of it, I don't really know if it's true. Let's assume that I give someone my code, will he have problems compiling it? Is it all right when I use and , or instead of && , || ? Or are these keywords really non-standard? P.S.I use the MinGW compiler. 回答1: They are in fact standard

Why 1103515245 is used in rand?

对着背影说爱祢 提交于 2020-01-09 12:39:29
问题 I'm talking about this surprisingly simple implementation of rand() from the C standard: static unsigned long int next = 1; int rand(void) /* RAND_MAX assumed to be 32767. */ { next = next * 1103515245 + 12345; return (unsigned)(next/65536) % 32768; } From this Wikipedia article we know that the multiplier a (in above code a = 1103515245 ) should fulfill only 2 conditions: a - 1 is divisible by all prime factors of m . (In our case m = 2^32 , size of the int, so m has only one prime factor =

Why do compilers allow string literals not to be const?

喜欢而已 提交于 2020-01-07 03:04:06
问题 And where are literals in memory exactly? (see examples below) I cannot modify a literal, so it would supposedly be a const char*, although the compiler let me use a char* for it, I have no warnings even with most of the compiler flags. Whereas an implicit cast of a const char* type to a char* type gives me a warning, see below (tested on GCC, but it behaves similarly on VC++2010). Also, if I modify the value of a const char (with a trick below where GCC would better give me a warning for),

Standards for queries over SOAP

我的未来我决定 提交于 2020-01-04 09:16:47
问题 Is there a standards-sanctioned XML format for describing entity queries? Background: I plan to build a library for writing queries over WCF services. On the client I want to be able to write (C#): var customers = from c in service.Customers where c.Name.StartsWith("P") order by c.Name select c; I will use a custom serializer to turn the LINQ query into an XML format to send as part of the SOAP body to the server. Maybe it would look something like this: <query> <fetch entity="Customer"> <all

C++ call stack not in standard?

≯℡__Kan透↙ 提交于 2020-01-04 06:04:29
问题 Does the C++ standard talk about the call stack? It's common knowledge how stack and heap are used in C++, but I was reading through the standard and found no mention of it. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf Is this something that's left up to the compiler implementation, but everyone agrees on, or did I miss something while browsing the doc? 回答1: It isn't mentioned in the standard. Neither the stack nor the heap are. The standard describes the syntax and the

C++ call stack not in standard?

孤者浪人 提交于 2020-01-04 06:04:20
问题 Does the C++ standard talk about the call stack? It's common knowledge how stack and heap are used in C++, but I was reading through the standard and found no mention of it. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf Is this something that's left up to the compiler implementation, but everyone agrees on, or did I miss something while browsing the doc? 回答1: It isn't mentioned in the standard. Neither the stack nor the heap are. The standard describes the syntax and the

May wchar_t be promoted to wint_t?

孤者浪人 提交于 2020-01-04 02:18:25
问题 I see one contradiction of glibc reference and Amendment 1 to C90. The quote from glibc reference says that wchar_t may be promoted to wint_t: if wchar_t is defined as char the type wint_t must be defined as int due to the parameter promotion But AMD1 says this: Currently, an existing implementation could have wchar_t be int and wint_t be long, and default promotions would not change int to long. Basically, this is due to wchar_t and wint_t being typedefs. Hence, we will not now have wchar_t

Can an implementation specify undefined behavior

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-03 19:14:46
问题 3.4.1 1 implementation-defined behavior unspecified behavior where each implementation documents how the choice is made Can an implementation specify that, implementation-defined behavior is undefined behavior in cases where undefined behavior is a possible outcome? For example: 6.3.1.3 Signed and unsigned integers 3 Otherwise, the new type is signed and the value cannot be represented in it; either the result is implementation-defined or an implementation-defined signal is raised. So as long

How are cells of a table impacted by declaring an event in a col element?

扶醉桌前 提交于 2020-01-03 10:18:13
问题 When an event, such as onclick, is declared in a col element for an HTML table does that event impact the cells referenced by the col element? Is the event ignored? Does something else happen? 回答1: Great question. The spec says: <!ATTLIST COL -- column groups and properties -- %attrs; -- %coreattrs, %i18n, %events --- where %events says: <!ENTITY % events "onclick %Script; #IMPLIED -- a pointer button was clicked -- ondblclick %Script; #IMPLIED -- a pointer button was double clicked--

How are cells of a table impacted by declaring an event in a col element?

早过忘川 提交于 2020-01-03 10:18:02
问题 When an event, such as onclick, is declared in a col element for an HTML table does that event impact the cells referenced by the col element? Is the event ignored? Does something else happen? 回答1: Great question. The spec says: <!ATTLIST COL -- column groups and properties -- %attrs; -- %coreattrs, %i18n, %events --- where %events says: <!ENTITY % events "onclick %Script; #IMPLIED -- a pointer button was clicked -- ondblclick %Script; #IMPLIED -- a pointer button was double clicked--