357mag 3 Posted December 30, 2024 (edited) I'm looking around the IDE for something that will allow me to add a header file to my project. Do I right-click on the project and just select Add Unit? I also need to add a .cpp file too. Edited December 30, 2024 by 357mag Share this post Link to post
357mag 3 Posted December 30, 2024 (edited) Oh I believe I found it. Anyway I made my first project that uses a header file to hold the function prototype, and a .cpp file that holds the implementation. The int main( ) file I named Odd Or Even.cpp (The program determines whether two numbers are odd or even). The header file I added to the program it holds the function prototype I named it MyLib.h The additional .cpp file I added that holds the implementation I named it MyLib.cpp I'm not too clear on the last file which C++ Builder generates when you create a new project. C++ Builder calls it PCH1.h. Here it is: #ifdef _WIN32 #include <tchar.h> #endif bool isEven(int number); But it seems like I have two function prototypes going on. One here in this PCH1.h file, and the other one in the MyLib.h file. I had to place the function prototype here because the compiler complained about an undeclared identifier without it. Then I commented out the prototype in the MyLib.h file and rebuilt the project and it ran fine so I deleted that file. But what is this PCH1.h file about with this code that automatically comes with it? PCH stands for what? Edited December 30, 2024 by 357mag Share this post Link to post
Roger Cigol 107 Posted December 30, 2024 PCH = pre compiled header. It's a file created at a full build by the compiler with the pure aim of speeding up compilation. In almost all cases you can just ignore it and let the compiler delete/recreate it as it needs to. Share this post Link to post
Roger Cigol 107 Posted December 30, 2024 If you add a unit then the IDE adds both the *.cpp and .h files. There can be cases where you have a .h file with no associated *.cpp file (and this is therefore not what the IDE calls a unit). In this case you can right click on the project name (= the exe file) in the project tree view and select add existing and navigate to the *.h file you want to add. Share this post Link to post
Remy Lebeau 1440 Posted December 30, 2024 12 hours ago, 357mag said: But what is this PCH1.h file about with this code that automatically comes with it? PCH stands for what? C++ Precompiled Header File (*.pch) Precompiled Headers Overview Share this post Link to post