standards

List or longer code snippet inside paragraph

馋奶兔 提交于 2019-11-28 02:19:24
When writing about algorithms, it is often very convenient to write some (pseudo)code inside a paragraph, or even in the middle of a sentence . To visually support the structure of a more complex sentence, lists come handy too. Obviously, one sentence must not be split across different paragraphs. But in our case it has to be due to HTML nesting rules. Paragraph is the p element , which cannot contain block-level elements . Unfortunately for our case, pre and lists are block-level . If I do not obey the spec and include pre or ol / ul / dl in a p , the p is automatically closed right before

Is a compiler allowed to add functions to standard headers?

瘦欲@ 提交于 2019-11-28 01:55:56
Is a C compiler allowed to add functions to standard headers and still conform to the C standard? I read this somewhere, but I can't find any reference in the standard, except in annex J.5: The inclusion of any extension that may cause a strictly conforming program to become invalid renders an implementation nonconforming. Examples of such extensions are new keywords, extra library functions declared in standard headers , or predefined macros with names that do not begin with an underscore. However, Annex J is informative and not normative... so it isn't helping. So I wonder if it is okay or

Why statements cannot appear at namespace scope?

本秂侑毒 提交于 2019-11-28 01:36:17
Any idea on which rule in standard states the statements like this: p++; //where 'p' is pointer to array cannot appear in global scope? I'm looking for a reference not just an explanation if possible. Nawaz The expression p++ which you've written is at namespace scope. It is forbidden by the grammer of namespace-body which is defined in §7.3.1/1 as: namespace-body: declaration-seq opt which says the namespace-body can optionally contain only declaration . And p++ is surely not a declaration, it is an expression, therefore the Standard implicitly forbids it. The Standard might have explicit

Passing NON-POD type to Variadic function is undefined behavior?

廉价感情. 提交于 2019-11-28 00:55:58
In this document , the author said Only a POD-type can be an argument for the ellipsis "..." while std::string is not a POD-type. I'm understanding this as Passing NON-POD type to Variadic function is undefined behavior . Is it right? Though, is he saying C/C++ standard? I tried to find it at n3242 C++ spec. But can not find. I'd like to know I'm understanding rightly and this is a standard. Mike Seymour It's specified in C++11 5.2.2/7: Passing a potentially-evaluated argument of class type having a non-trivial copy constructor, a non-trivial move contructor, or a non-trivial destructor, with

why is char's sign-ness not defined in C?

≯℡__Kan透↙ 提交于 2019-11-28 00:40:59
The C standard states: ISO/IEC 9899:1999, 6.2.5.15 (p. 49) The three types char, signed char, and unsigned char are collectively called the character types. The implementation shall define char to have the same range, representation, and behavior as either signed char or unsigned char. And indeed gcc define that according to target platform. My question is, why does the standard do that? I can see nothing that can come out of ambiguous type definition, except of hideous and hard to spot bugs. More than so, in ANSI C (before C99), the only byte-sized type is char, so using char for math is

Node.TEXT_NODE and IE7

佐手、 提交于 2019-11-27 23:38:54
I've some javascript that tests DOM node types against like this: if(node.nodeType == Node.TEXT_NODE) { Of course, it all works fine in Firefox, Safari, and Opera. But Internet Explorer 7 is complaining that Node (with the capital N) is undefined. But that's part of DOM Level 2 ! Do I really need to change my code to use magic numbers? Or am I missing something simple here? Unfortunately you are not missing anything. There is no Node constant in IE. Look here http://www.ibm.com/developerworks/xml/library/x-matters41.html at section "What else can you do with the DOM?". So either you define

Why would you use “AS” when aliasing a SQL table?

蹲街弑〆低调 提交于 2019-11-27 23:33:59
I just came across a SQL statement that uses AS to alias tables, like this: SELECT all, my, stuff FROM someTableName AS a INNER JOIN someOtherTableName AS b ON a.id = b.id What I'm used to seeing is: SELECT all, my, stuff FROM someTableName a INNER JOIN someOtherTableName b ON a.id = b.id I'm assuming there's no difference and it's just syntactic sugar, but which of these is more prevalent/wide-spread? Is there any reason to prefer one over the other? Edited to clarify: I appreciate all the answers and all the points made, but the question was not why or why not to use table aliases. The

In C++, when can two variables of the same name be visible in the same scope?

会有一股神秘感。 提交于 2019-11-27 23:13:16
This code illustrates something that I think should be treated as bad practice, and elicit warnings from a compiler about redefining or masking a variable: #include <iostream> int *a; int* f() { int *a = new int; return a; } int main() { std::cout << a << std::endl << f() << std::endl; return 0; } Its output (compiled with g++): 0 0x602010 I've looked at a couple references (Stroustrup and The Complete C++ Reference) and can't find anything about when and why this is allowed. I know that it's not within a single local scope, though. When and why is this allowed? Is there a good use for this

Can an ANSI C-compliant implementation include additional functions in its standard library?

霸气de小男生 提交于 2019-11-27 23:07:21
Is an ANSI C-compliant implementation allowed to include additional types and functions in its standard library, beyond those enumerated by the standard? (An ideal answer would reference the relevant part of the ANSI standard.) I ask particularly because Mac OS 10.7 declares the getline function in stdio.h, even when compiling with gcc or clang using the -ansi flag. This breaks several older programs that define their own getline function. Is this a fault of Mac OS 10.7? (The man page for getline on Mac OS 10.7 says that getline conforms to the POSIX.1 standard, which came in 2008.) Edit: To

How to send NULL in HTTP query string?

心已入冬 提交于 2019-11-27 23:05:07
I'm developing an API that can accept the main three data types as values to query string parameters: boolean , string & numeric ( integer or float ). By default, everything is retrieved a string (I don't think there's a way around that), but the parameters are configured with a type so that I convert them to the proper type. I now need to start accepting NULL as a value, for all three data types, but I'm not sure what is the best way to do so. Some people seem to accept no value as NULL ( ?param , without = ), but that is no quite working for me: I'm already accepting that as true for