standards

Are there any restrictions to the C standard allowing functions to be implemented as macros?

梦想的初衷 提交于 2019-12-01 16:37:30
问题 Often, in addition to providing a function declaration, C standard headers may provide a "masking macro" to make things speedier. For example, if I include ctype.h , the header file will declare int isdigit(int c); But it may also mask the declaration with a macro. I believe this is a portable isdigit macro according to the C standard: #define isdigit(c) ((c) >= '0' && (c) <= '9') Of course, this macro is also dangerous because it introduces undefined behavior if you do this while the macro

What's stopping me from using arbitrary tags in HTML?

守給你的承諾、 提交于 2019-12-01 16:01:13
Even the new HTML5 tags aren't enough to describe structures without falling back to div s. What's stopping me from changing: <div class="post"> <div class="userinfo"> <span class="name">Casey</span> <img class="avatar" src="..." /> </div> <div class="body"> <p>blah blah blah</p> <p>blah blah blah</p> <p>blah blah blah</p> </div> </div> into something like: <post> <userinfo> <name>Casey</name> <img class="avatar" src="..." /> </userinfo> <pbody> <p>blah blah blah</p> <p>blah blah blah</p> <p>blah blah blah</p> </pbody> </post> To me, the second example is a lot cleaner. Is there anything (i.e.

JavaScript event handlers execution order

你说的曾经没有我的故事 提交于 2019-12-01 15:47:19
问题 Having this JS code: document.getElementById('e1').addEventListener('click', function(){alert('1');}, false); document.getElementById('e2').addEventListener('click', function(){alert('2');}, false); document.getElementById('e1').click(); document.getElementById('e2').click(); I'm wondering in what order will the alerts show up - will it be in the order the events were triggered by click() or could it be random? I'm asking about documented/standardised behaviour, not about what browsers

Standard (cross-platform) way for bit manipulation

自闭症网瘾萝莉.ら 提交于 2019-12-01 15:28:11
As are are different binary representation of the numbers (for example, take big/little endian), is this cross-platform: // NOTE: FIXED-SIZE unsigned integral type some_unsigned_type variable = some_number; // set n-th bit, starting from 1, // right-to-left (least significant-to most significant) variable |= ( 1 << ( n - 1 ) ); // clear the same bit: variable &= ~( 1 << ( n - 1 ) ); In other words, does the compiler always take care of the different binary representation of the fixed size unsigned numbers, or it's platform-specific? And what if variable is signed integral type (for example,

Bitfields, why implementation specific?

心不动则不痛 提交于 2019-12-01 15:23:12
C/C++ bitfields seem to have a lot of application in hardware drivers and binary network transfers. However they don't seem to be widely used and are generally discouraged, because the actual binary layout is implementation specific, as seen in this quote from the C99 standard 6.7.2.1/10 - "Structure and union specifiers"; An implementation may allocate any addressable storage unit large enough to hold a bitfield. If enough space remains, a bit-field that immediately follows another bit-field in a structure shall be packed into adjacent bits of the same unit. If insufficient space remains,

Is it poor form to use CLASS attributes with no corresponding CSS rule? [duplicate]

老子叫甜甜 提交于 2019-12-01 15:16:17
This question already has an answer here: Can I use non existing CSS classes? 13 answers For example if I wanted to select some elements with a certain class using jQuery, and for that reason only, is it always expected that those classes SHOULD be defined in the css?. <div class="xyz"> something </div> <div class="xyz"> something else </div> //with example jQuery $(".xyz").hide(); //is it wrong no element 'xyz' is defined in css? Using CSS classes and - depending on the case - IDs (unique!!) is perfectly fine and often the only solution to keep your HTML code valid while giving additional

Why size_t when int would suffice for the size of an array?

我们两清 提交于 2019-12-01 15:12:13
The C standard guarantees that an int is able to store every possible array size. At least, that's what I understand from reading §6.5.2.1, subsection 1 (Array subscripting constraints): One of the expressions shall have type ‘‘pointer to object type’’, the other expression shall have integer type, and the result has type ‘‘type’’. Since we shall use int s as array subscripts, why are we supposed to use size_t to determine the size of an array? Why does strlen() return size_t when int would suffice? The term "integer type" doesn't mean int - for example, char , and short are integer types.

What's stopping me from using arbitrary tags in HTML?

走远了吗. 提交于 2019-12-01 15:00:39
问题 Even the new HTML5 tags aren't enough to describe structures without falling back to div s. What's stopping me from changing: <div class="post"> <div class="userinfo"> <span class="name">Casey</span> <img class="avatar" src="..." /> </div> <div class="body"> <p>blah blah blah</p> <p>blah blah blah</p> <p>blah blah blah</p> </div> </div> into something like: <post> <userinfo> <name>Casey</name> <img class="avatar" src="..." /> </userinfo> <pbody> <p>blah blah blah</p> <p>blah blah blah</p> <p

Bitfields, why implementation specific?

荒凉一梦 提交于 2019-12-01 14:21:35
问题 C/C++ bitfields seem to have a lot of application in hardware drivers and binary network transfers. However they don't seem to be widely used and are generally discouraged, because the actual binary layout is implementation specific, as seen in this quote from the C99 standard 6.7.2.1/10 - "Structure and union specifiers"; An implementation may allocate any addressable storage unit large enough to hold a bitfield. If enough space remains, a bit-field that immediately follows another bit-field

Standard (cross-platform) way for bit manipulation

点点圈 提交于 2019-12-01 14:19:57
问题 As are are different binary representation of the numbers (for example, take big/little endian), is this cross-platform: // NOTE: FIXED-SIZE unsigned integral type some_unsigned_type variable = some_number; // set n-th bit, starting from 1, // right-to-left (least significant-to most significant) variable |= ( 1 << ( n - 1 ) ); // clear the same bit: variable &= ~( 1 << ( n - 1 ) ); In other words, does the compiler always take care of the different binary representation of the fixed size