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
Compile time
(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!
== Overview == Most compilers have at least the following compiler phases (which therefore occur at compile-time): [[syntax analysis]], [[semantic analysis (computer science)|semantic analysis]], and [[code generation (compiler)|code generation]]. During optimization phases, constant expressions in the source code can also be evaluated at compile-time using [[compile-time function execution|''compile-time execution'']], which reduces the constant expressions to an immediate, single value.<ref>{{Cite web |last=Yongwei |first=Wu |date=October 7, 2024 |title=C++ Compile-Time Programming |url=https://accu.org/journals/overload/32/183/wu/ |access-date=2025-04-26 |website=accu.org |language=en-gb}}</ref><ref>{{Cite web |title=Compile Time Evaluation |url=https://c3-lang.org/generic-programming/compiletime/ |access-date=2025-04-26 |website=C3 |language=en}}</ref> This is not necessary for correctness, but to improve program performance during runtime. Programming language definitions usually specify compile time requirements that source code must meet to be successfully compiled. For example, languages may stipulate that the amount of storage required by types and variables can be deduced. Properties of a program that can be reasoned about at compile time include [[range check|range-check]]s (e.g., proving that an array index will not exceed the array bounds), [[deadlock (computer science)|deadlock]] freedom in [[concurrent language]]s, or timings (e.g., proving that a sequence of code takes no more than an allocated amount of time). For statically-typed languages such as [[Java (programming language)|Java]] or [[Rust (programming language)|Rust]], types are checked at compile time to ensure [[type safety]].<ref>{{Cite web |title=Data Types - The Rust Programming Language |url=https://doc.rust-lang.org/stable/book/ch03-02-data-types.html |access-date=2025-04-26 |website=doc.rust-lang.org}}</ref> Compile-time occurs before [[link time]] (when the output of one or more compiled files are joined) and [[Run time (program lifecycle phase)|runtime]] (when a [[computer program|program]] is [[Execution (computing)|executed]]). However, in the case of [[dynamic compilation]], the final transformations into [[machine language]] happen at run time. Some compile-time operations can also be deferred to link-time while still not incurring a run-time cost.
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)