standards-compliance

“as if” in language standards

你离开我真会死。 提交于 2019-11-28 02:49:56
问题 What is the exact meaning of the phrase "as if" in the standard and how does it work when a user can modify individual parts of the behavior. The question is in regards to the C++ standard when talking about the nothrow version of operator new . 18.4.1.1/7 reads (my emphasis): This nothrow version of operator new returns a pointer obtained as if acquired from the ordinary version. My understanding is that "as if" does not require a specific implementation as long as the behavior is

Kernel's “container_of” - any way to make it ISO conforming?

房东的猫 提交于 2019-11-27 23:36:09
问题 While looking at Linux kernel's implementation of doubly linked circular lists, I've found following macro: #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) The way this works is that it returns pointer to structure given only address of one of its members: struct blabla { int value; struct list_head *list; } Thus you can get pointer to blabla (and get to "value") given only pointer to

Valid characters for URI schemes?

孤人 提交于 2019-11-27 17:14:51
问题 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 .

Clean way to launch the web browser from shell script?

∥☆過路亽.° 提交于 2019-11-27 17:11:50
In a bash script, I need to launch the user web browser. There seems to be many ways of doing this: $BROWSER xdg-open gnome-open on GNOME www-browser x-www-browser ... Is there a more-standard-than-the-others way to do this that would work on most platforms, or should I just go with something like this: #/usr/bin/env bash if [ -n $BROWSER ]; then $BROWSER 'http://wwww.google.com' elif which xdg-open > /dev/null; then xdg-open 'http://wwww.google.com' elif which gnome-open > /dev/null; then gnome-open 'http://wwww.google.com' # elif bla bla bla... else echo "Could not detect the web browser to

How to programmatically turn off quirks mode in IE8 WebBrowser control?

那年仲夏 提交于 2019-11-27 13:35:28
I want to use IE8 as a WebBrowser control in a C# application. How can I disable "quirks mode" and force IE into standards compliance (as far as it is implemented)? I think the issue you're facing is described in IEBlog: WebBrowser Control Rendering Modes in IE8 : While webmasters can easily alter their site to render properly in the new version of IE, many software vendors do not have the resources to instantly push out new versions of their applications with updated internal pages. In order to ensure that these existing applications remain in working order, IE8 renders pages running within

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

谁说我不能喝 提交于 2019-11-27 11:54:24
问题 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)? 回答1:

Defined behaviour for expressions

北战南征 提交于 2019-11-27 08:07:35
The C99 Standard says in $6.5.2. Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be read only to determine the value to be stored . (emphasis by me) It goes on to note, that the following example is valid (which seems obvious at first) a[i] = i; While it does not explicitly state what a and i are. Although I believe it does not, I'd like to know whether this example covers the following case: int i = 0, *a = &i; a[i] = i; This will not change the value of i , but

Defining functions after return

☆樱花仙子☆ 提交于 2019-11-27 07:51:36
问题 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)? 回答1: You can see that the

Why does C++ allow variable length arrays that aren't dynamically allocated?

我们两清 提交于 2019-11-27 05:35:54
I'm relatively new to C++, and from the beginning it's been drilled into me that you can't do something like int x; cin >> x; int array[x]; Instead, you must use dynamic memory. However, I recently discovered that the above will compile (though I get a -pedantic warning saying it's forbidden by ISO C++). I know that it's obviously a bad idea to do it if it's not allowed by the standard, but I previously didn't even know this was possible. My question is, why does g++ allow variable length arrays that aren't dynamically allocated if it's not allowed by the standard? Also, if it's possible for

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

百般思念 提交于 2019-11-27 03:02:23
问题 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),