Creating Projects
Projects are the intended way of managing files and modules in C3. They make many things easier, like adding libraries or running test.
To create a new project you can simply run the following command in the terminal.
c3c init <c3project>Project Structure
Open the project with your code editor of choice. You should now find the following folder structure.
-
-
-
-
-
-
- main.c3
-
- LICENSE
- project.json
- README.md
Believe it or not, every one of these folders and files has a use.
Understanding Project Files and Folders
| Folder/File | Description |
|---|---|
build |
Contains binary or executable together with temporary files when you build your project. |
docs |
Contains documentation. |
lib |
Contains C3 libraries. |
resources |
Contains non-code resources like images, audio files or 3D models. |
scripts |
Contains C3 files, whose output to the terminal can be inserted into your source code. Check the documentation for more info. |
src |
Contains your projects source code. |
src/main.c3 |
The main function inside of main.c3 is the entry point to your C3 program. |
test |
Contains tests. |
LICENSE |
Contains project license. |
project.json |
Contains project configurations. |
README.md |
Contains useful or important information about your project. |
Building and Running your Project
To build your C3 project you can simply run the following command.
c3c buildYou can take a look inside of your build directory now. Depending on your operating system you should find a binary or an executable named after your project. To run your program you can use this command:
./build/c3projectIt should print Hello, World! into your console.
Now doing these two steps every time seems like a hassle, wouldn’t it be nice to have a command that does them for us? Well lucky for us C3 offers this in the form of the run command. Using it like so:
c3c runwill take care of building and executing.
Congrats, you are now able to understand how C3 projects are structured and how you can build and run your own project.