]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/jit/docs/cp/intro/tutorial01.rst
Update copyright years.
[thirdparty/gcc.git] / gcc / jit / docs / cp / intro / tutorial01.rst
1 .. Copyright (C) 2014-2020 Free Software Foundation, Inc.
2 Originally contributed by David Malcolm <dmalcolm@redhat.com>
3
4 This is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see
16 <http://www.gnu.org/licenses/>.
17
18 .. default-domain:: cpp
19
20 Tutorial part 1: "Hello world"
21 ==============================
22
23 Before we look at the details of the API, let's look at building and
24 running programs that use the library.
25
26 Here's a toy "hello world" program that uses the library's C++ API to
27 synthesize a call to `printf` and uses it to write a message to stdout.
28
29 Don't worry about the content of the program for now; we'll cover
30 the details in later parts of this tutorial.
31
32 .. literalinclude:: ../../examples/tut01-hello-world.cc
33 :language: c++
34
35 Copy the above to `tut01-hello-world.cc`.
36
37 Assuming you have the jit library installed, build the test program
38 using:
39
40 .. code-block:: console
41
42 $ gcc \
43 tut01-hello-world.cc \
44 -o tut01-hello-world \
45 -lgccjit
46
47 You should then be able to run the built program:
48
49 .. code-block:: console
50
51 $ ./tut01-hello-world
52 hello world