Write a Hello World application with C
This section outlines the steps to write a C program in Geany.
Launch Geany:

Select Project > New. Name the project hello_world_c:

The Name field is the name for the project. The Filename field is the path for the file representing the project and it stores the project settings. It generally ends in .geany. The Base path field is the base path of all files making up the project:

Click OK when prompted to create the directory:

Write a Hello World sample application. Save it as hello_world.c:

Select Build > Compile to compile the source:

Select Build > Build to create an executable for the code:

Select Build > Execute to execute the code in a terminal window:


Try the linting function by adding the following code after your print statement:
char *buf = NULL; printf("%d", *buf);Select Build > Lint:

You should see a warning for dereferencing a NULL pointer:

Next, try debugging the Hello World sample. Update the compile commands to include the
-gflag by selecting Build > Properties:
Select the Build tab and update the Compile and Build commands to include
-g:

Select Debug > Setup Program:

Enter the full path to the hello_world executable, then click OK:

Set a breakpoint on the printf() statement. Click the line in the IDE, then select Debug > Toggle Breakpoint:



Select Debug > Run/Continue to run the debugger:

Once the breakpoint has been hit, select Debug > Run/Continue or Debug > Step Over:


Next steps
You can override the default commands for C files in /home/qnxuser/.config/geany/filedefs.
For more information on how to modify the default commands, refer to the "Adjusting build commands" section in the "Customizing Geany" page.
For more information on how to customize the lint commands, refer to the Clang-Tidy documentation at https://clang.llvm.org/extra/clang-tidy/.
