standards-compliance

Valid characters for URI schemes?

喜欢而已 提交于 2019-11-29 02:58:58
I was thinking about Registering an Application to a URL Protocol and I'd like to know, what characters are allowed in a scheme? Some examples: h323 (has numbers) h323:[<user>@]<host>[:<port>][;<parameters>] z39.50r (has a . as well) z39.50r://<host>[:<port>]/<database>?<docid>[;esn=<elementset>][;rs=<recordsyntax>] paparazzi:http (has a : ) paparazzi:http:[//<host>[:[<port>][<transport>]]/ So, what characters can I fancy using? Can we have... @:TwitterUser #:HashTag $:CapitalStock ?:ID-10T ...etc., as desired, or characters in the scheme are restricted by standard? According to RFC 2396 ,

Is pointer tagging in C undefined according to the standard?

本小妞迷上赌 提交于 2019-11-28 23:39:54
Some dynamically-typed languages use pointer tagging as a quick way to identify or narrow down the runtime type of the value being represented. A classic way to do this is to convert pointers to a suitably sized integer, and add a tag value over the least significant bits which are assumed to be zero for aligned objects. When the object needs to be accessed, the tag bits are masked away, the integer is converted to a pointer, and the pointer is dereferenced as normal. This by itself is all in order, except it all hinges on one colossal assumption: that the aligned pointer will convert to an

Why class { int i; }; is not fully standard-conformant?

 ̄綄美尐妖づ 提交于 2019-11-28 19:06:37
This is a follow-up question. In the previous question , @JohannesSchaub-litb said that the following code is not fully standard-conformant: class { int i; }; //unnamed-class definition. § 9/1 allows this! and then he added, while it is grammatically valid, it breaks the rule that such a class must declare at least one name into its enclosing scope. I couldn't really understand this. What name is he talking about? Could anyone elaborate on this further (preferably quoting the Standard)? Clause 9 of the standard allows class {public: int i;} (note the lack of a final semicolon) because this

Most efficient standard-compliant way of reinterpreting int as float

只谈情不闲聊 提交于 2019-11-28 18:38:13
Assume I have guarantees that float is IEEE 754 binary32. Given a bit pattern that corresponds to a valid float, stored in std::uint32_t , how does one reinterpret it as a float in a most efficient standard compliant way? float reinterpret_as_float(std::uint32_t ui) { return /* apply sorcery to ui */; } I've got a few ways that I know/suspect/assume have some issues: Via reinterpret_cast , float reinterpret_as_float(std::uint32_t ui) { return reinterpret_cast<float&>(ui); } or equivalently float reinterpret_as_float(std::uint32_t ui) { return *reinterpret_cast<float*>(&ui); } which suffers

How universally is C99 supported?

 ̄綄美尐妖づ 提交于 2019-11-28 17:46:06
How universally is the C99 standard supported in today's compilers? I understand that not even GCC fully supports it. Is this right? Which features of C99 are supported more than others, i.e. which can I use to be quite sure that most compilers will understand me? If you want to write portable C code, then I'd suggest you to write in C89 (old ANSI C standard). This standard is supported by most compilers. The Intel C Compiler has very good C99 support and it produces fast binaries. (Thanks 0x69 !) MSVC supports some new features and Microsoft plan to broaden support in future versions. GCC

Defining functions after return

巧了我就是萌 提交于 2019-11-28 13:36:01
I'm currently reading John Papa's AngularJS style guide and saw the code : function dataService() { var someValue = ''; var service = { save: save, someValue: someValue, validate: validate }; return service; //////////// function save() { /* */ }; function validate() { /* */ }; } You can see that the functions save and validate are defined after the function returned a value. How does this work? Is it standard-compliant and works in all browsers (say, from IE 6)? You can see that the functions save and validate are defined after the function returned a value. That's what it looks like from

Using the correct, or preferable, not equal operator in MySQL

谁说胖子不能爱 提交于 2019-11-28 09:36:17
Which of the two (semantically equivalent) ways is preferable to test for inequality? 'foo' != 'bar' (exclamation mark and equals sign) 'foo' <> 'bar' (less than and greater than chevron symbols together) The MySQL documentation clearly indicates that there is no difference between them and yet some people seem to be attached to only doing it one way or the other. Maybe this is just another pointless vi vs. emacs debate but when other people are reading your code (and therefore your queries), it's useful to maintain some consistency. <> looks a lot like <=> which is a very underused operator

<!DOCTYPE html> and older browsers

半腔热情 提交于 2019-11-28 08:22:33
Does <!DOCTYPE html> trigger standards mode for older browsers as well? Saying "in all modern browsers" isn't very precise. I am especially interested in IE6. Thank you. This is how the HTML5 doctype came into existance (in layman's terms): The guys who make the standards wanted a simpler doctype. They found out that <!DOCTYPE html> (which is as simple as it gets) does trigger standards mode in browsers. They decided to standardize it in HTML5. True story. Yes, it does trigger (Almost) Standards Mode in older browsers (such as IE6). See: http://hsivonen.iki.fi/doctype/ Standards mode, cutting

One-byte-off pointer still valid in C?

牧云@^-^@ 提交于 2019-11-28 08:04:29
问题 I might be mistaken, but I seem to remember that for a given memory allocation, e.g. char *p = malloc(4); the pointer p is a valid pointer for all bytes within the allocation and for the first byte beyond that allocation. Thus, to access memory through the pointer p only offsets p[0] .. p[3] are valid. But for pointer comparison &( p[4] ) would also be be a valid pointer. Is that correct, and where in the C Standard (link) does it say so? It seems that 6.5.9 p6 might hint into the right

What is going on with 'gets(stdin)' on the site coderbyte?

社会主义新天地 提交于 2019-11-28 04:26:15
Coderbyte is an online coding challenge site (I found it just 2 minutes ago). The first C++ challenge you are greeted with has a C++ skeleton you need to modify: #include <iostream> #include <string> using namespace std; int FirstFactorial(int num) { // Code goes here return num; } int main() { // Keep this function call here cout << FirstFactorial(gets(stdin)); return 0; } If you are little familiar with C++ the first thing * that pops in your eyes is: int FirstFactorial(int num); cout << FirstFactorial(gets(stdin)); So, ok, the code calls gets which is deprecated since C++11 and removed