Inline function linkage

When the function in the header is not inline, then multiple definitions of this function (e.g. in multiple translation units) is a violation of ODR rules. Inline functions by default have external linkage. Hence, as a consequence of ODR rules (given below), such multiple definitions (e.g. in multiple translation units) are Okay: $3.2/5- “There can … Read more

Margin top in inline element

This is not Firefox-only, and defined in the CSS 2.1 Specification: 8.3 Margin properties: ‘margin-top’, ‘margin-right’, ‘margin-bottom’, ‘margin-left’, and ‘margin’ Margin properties specify the width of the margin area of a box. The ‘margin’ shorthand property sets the margin for all four sides while the other margin properties only set their respective side. These properties … Read more

Does constexpr imply inline?

Yes ([dcl.constexpr], ยง7.1.5/2 in the C++11 standard): “constexpr functions and constexpr constructors are implicitly inline (7.1.2).” Note, however, that the inline specifier really has very little (if any) effect upon whether a compiler is likely to expand a function inline or not. It does, however, affect the one definition rule, and from that perspective, the … Read more

What is the use of the `inline` keyword in C?

A C code can be optimized in two ways: For Code size and for Execution Time. inline functions: gcc.gnu.org says, By declaring a function inline, you can direct GCC to make calls to that function faster. One way GCC can achieve this is to integrate that function’s code into the code for its callers. This … Read more

How to pass event as argument to an inline event handler in JavaScript?

to pass the event object: <p id=”p” onclick=”doSomething(event)”> to get the clicked child element (should be used with event parameter: function doSomething(e) { e = e || window.event; var target = e.target || e.srcElement; console.log(target); } to pass the element itself (DOMElement): <p id=”p” onclick=”doThing(this)”> see live example on jsFiddle. You can specify the name … Read more