![]() This saves us time and avoids the potential for errors to occur from us having to copy code manually between files. When compiling our C++ program, the pre-processor takes this #include and copy-paste’s the code defined in that header file into the file that includes it. To link code in one file with that in another, we use the #include directive. ![]() The exact nature of what the pre-processor does depends on the pre-processor directive.įor example, we often split code into separate files to make it easier to organize and read. ![]() The first stage of compiling a C++ program, using the pre-processor, involves carrying out these behaviors. You can read more about pre-processor directives here. This first article will look at learning how to compile a C++ program.Ĭ++ has pre-processor directives that are identified in the code by the prefix #, which defines behaviors that are to be carried out on the source code before it’s compiled. Therefore, I want to write a series of articles exploring many of the issues I have discussed. The focus is mostly on problem-solving and C++ syntax and yet, if you want to do any serious game programming in C++ without writing everything from scratch, this knowledge is required. This knowledge isn’t something that I have found to be taught. ![]() In reality, this shouldn’t be the difficult part of building your game. This meant that I simply did not know how to incorporate a library into my code, or I’d be banging my head against a wall trying to resolve errors that occurred when trying to compile. I didn’t understand how my source code was turned into an executable or library, nor did I understand how to compile platform-independent code. I struggled because I simply didn’t understand how C++ programs were built and distributed over the internet. One of the hardest things I found when first learning C++, outside of learning about pointers and memory management, was how to successfully compile code using third-party libraries.Īs a game developer, you rely a lot on libraries for aspects of your game, such as rendering and physics, and it can be surprisingly tricky to successfully compile an empty project with these libraries included.
0 Comments
Leave a Reply. |