Inline functions vs Preprocessor macros

Preprocessor macros are just substitution patterns applied to your code. They can be used almost anywhere in your code because they are replaced with their expansions before any compilation starts. Inline functions are actual functions whose body is directly injected into their call site. They can only be used where a function call is appropriate. … Read more

Send inline image in email

Some minimal c# code to embed an image, can be: MailMessage mailWithImg = GetMailWithImg(); MySMTPClient.Send(mailWithImg); //* Set up your SMTPClient before! private MailMessage GetMailWithImg() { MailMessage mail = new MailMessage(); mail.IsBodyHtml = true; mail.AlternateViews.Add(GetEmbeddedImage(“c:/image.png”)); mail.From = new MailAddress(“yourAddress@yourDomain”); mail.To.Add(“recipient@hisDomain”); mail.Subject = “yourSubject”; return mail; } private AlternateView GetEmbeddedImage(String filePath) { LinkedResource res = new LinkedResource(filePath); … Read more

HTML: Changing colors of specific words in a string of text

<p style=”font-size:14px; color:#538b01; font-weight:bold; font-style:italic;”> Enter the competition by <span style=”color: #ff0000″>January 30, 2011</span> and you could win up to $$$$ — including amazing <span style=”color: #0000a0″>summer</span> trips! </p> Or you may want to use CSS classes instead: <html> <head> <style type=”text/css”> p { font-size:14px; color:#538b01; font-weight:bold; font-style:italic; } .date { color: #ff0000; } .season … Read more

React: inline conditionally pass prop to component

You were close with your idea. It turns out that passing undefined for a prop is the same as not including it at all, which will still trigger the default prop value. So you could do something like this: var parent = React.createClass({ propTypes: { editable: React.PropTypes.bool.isRequired, editableOpts: React.PropTypes.shape({…}) }, render: function() { return <Child … 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

Does it make any sense to use inline keyword with templates?

It is not irrelevant. And no, not every function template is inline by default. The standard is even explicit about it in Explicit specialization ([temp.expl.spec]) Have the following: a.cc #include “tpl.h” b.cc #include “tpl.h” tpl.h (taken from Explicit Specialization): #ifndef TPL_H #define TPL_H template<class T> void f(T) {} template<class T> inline T g(T) {} template<> … Read more

How can I tell gcc not to inline a function?

You want the gcc-specific noinline attribute. This function attribute prevents a function from being considered for inlining. If the function does not have side-effects, there are optimizations other than inlining that causes function calls to be optimized away, although the function call is live. To keep such calls from being optimized away, put asm (“”); … Read more

What’s the difference between “static” and “static inline” function?

By default, an inline definition is only valid in the current translation unit. If the storage class is extern, the identifier has external linkage and the inline definition also provides the external definition. If the storage class is static, the identifier has internal linkage and the inline definition is invisible in other translation units. If … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)