Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Inline expansion
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Comparison with macros == Traditionally, in languages such as [[C (programming language)|C]], inline expansion was accomplished at the source level using [[parameterized macro]]s. Use of true inline functions, as are available in [[C99]], provides several benefits over this approach: * In C, macro invocations do not perform [[type checking]], or even check that arguments are well-formed, whereas function calls usually do. * In C, a macro cannot use the return keyword with the same meaning as a function would do (it would make the function that asked the expansion terminate, rather than the macro). In other words, a macro cannot return anything which is not the result of the last expression invoked inside it. * Since C macros use mere textual substitution, this may result in unintended side-effects and inefficiency due to re-evaluation of arguments and [[order of operations]]. * Compiler errors within macros are often difficult to understand, because they refer to the expanded code, rather than the code the programmer typed. Thus, debugging information for inlined code is usually more helpful than that of macro-expanded code. * Many constructs are awkward or impossible to express using macros, or use a significantly different syntax. Inline functions use the same syntax as regular functions, and can be inlined and un-inlined at will with ease. Many compilers can also inline expand some [[Recursion (computer science)|recursive functions]];<ref>[https://web.archive.org/web/20041013180231/http://home.pipeline.com/~hbaker1/Inlines.html Inlining Semantics for Subroutines which are Recursive]" by Henry G. Baker</ref> recursive macros are typically illegal. [[Bjarne Stroustrup]], the designer of C++, likes to emphasize that macros should be avoided wherever possible, and advocates extensive use of inline functions.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)