Writing your first program
Writing a program in HPGCC3 is easy thanks to the Eclipse IDE. This tutorial will guide you step by step in the creation of a simple program.
Creating a project
Open the Eclipse IDE. If you just finished building the HPGCC3 libraries, the first step is to create your own workspace. Use the Switch workspace... menu option to create an empty workspace or switch to any other existing workspace. It is not a good idea to create your programs inside the libs_workspace or the tools_workspace that were used for the installation.
Once in the correct workspace, Go to the manu File -> New -> C Project. Give your project a name (helloworld), and make sure the HPGCC3 toolchain is selected. On the list on the left, just leave the 'Empty project' option selected. Click on Finish and your project should show on the Project explorer on the left.
Writing the program
Right-click on the name of the project and select 'New Source file'. Name it 'hworld.c' and this will open a new file in the editor.
Type the following code:
#include <hpgcc3.h> int main() { printf("Hello world!\n"); getchar(); return 0; }
Compiling
Now save the file and from the Project menu select Build, or simply hit ctrl-B. Your project should build without errors. In the project explorer, there should be now a new folder called Release, and inside this folder there should be a file called hworld.ex3.
The extension .ex3 is the official extension of an HPGCC3 executable.
Executing
Download the file hworld.ex3 to your calculator, or copy it to an SD card. To run it, simply put it on the calculator stack and hit EVAL (assuming RPN mode). You can also look for it with the filer, highlight the program and hit EVAL from within the filer.
If everything goes well you should see the famous Hello world! phrase on your screen, and you have compiled and executed your first program.
The sequence of creating a project, adding source files, compiling and executing is the basic development cycle for every HPGCC3 program.