Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
How to compile (without building) a .c/.cpp file with Xcode?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Raz0rEdge" data-source="post: 1445594" data-attributes="member: 110816"><p>What exactly does "compile without building" even mean? A quick primer on how this all works. A program can be comprised one one or multiple sources/header files..</p><p></p><p>If there is a single source file, it is first pre-processed by the compiler to evaluate all of the "#include", "#import", "#define", "#pragma" and other pre-processor directives. The file is then compiled into an object file, it is then finally linked against any necessary libraries to make it a functioning program.</p><p></p><p>The same process holds true for a project with multiple source files, you go through all the steps for each of the source files and deal with any cross-file dependencies as needed or report errors if things are messed up. Once it's all done, the final executable is created for execution.</p><p></p><p>Suppose you have a project with 3 source files, you modify one of them and then hit CMD+b, this will cause the compiler to determine which file changed, and go through the steps I described above and create the executable at that point. If you happen to do a CMD+r immediately after, the build will automatically run but since it's already up to date, nothing really happens except the message appearing and going to execute your program.</p><p></p><p>I'll have to check to see if there is a XCode option to prevent building when running, but that is usually a problem if you don't remember to build before you run. </p><p></p><p>Unless you are writing a VERY complicated program or running this on a Mac that is severely lacking in power, I can't imagine the few seconds it takes for the incremental builds or the minute it might take build the entire program is a huge deal.</p><p></p><p>I deal with building things that takes hours to complete so I know all about waiting..<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" /></p></blockquote><p></p>
[QUOTE="Raz0rEdge, post: 1445594, member: 110816"] What exactly does "compile without building" even mean? A quick primer on how this all works. A program can be comprised one one or multiple sources/header files.. If there is a single source file, it is first pre-processed by the compiler to evaluate all of the "#include", "#import", "#define", "#pragma" and other pre-processor directives. The file is then compiled into an object file, it is then finally linked against any necessary libraries to make it a functioning program. The same process holds true for a project with multiple source files, you go through all the steps for each of the source files and deal with any cross-file dependencies as needed or report errors if things are messed up. Once it's all done, the final executable is created for execution. Suppose you have a project with 3 source files, you modify one of them and then hit CMD+b, this will cause the compiler to determine which file changed, and go through the steps I described above and create the executable at that point. If you happen to do a CMD+r immediately after, the build will automatically run but since it's already up to date, nothing really happens except the message appearing and going to execute your program. I'll have to check to see if there is a XCode option to prevent building when running, but that is usually a problem if you don't remember to build before you run. Unless you are writing a VERY complicated program or running this on a Mac that is severely lacking in power, I can't imagine the few seconds it takes for the incremental builds or the minute it might take build the entire program is a huge deal. I deal with building things that takes hours to complete so I know all about waiting..:) [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
How to compile (without building) a .c/.cpp file with Xcode?
Top