Skip to content

Commit

Permalink
Improve readability of example code
Browse files Browse the repository at this point in the history
  • Loading branch information
cogu committed Mar 28, 2024
1 parent 14cb829 commit 308bbb6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Notable changes.

## [Unreleased]

### Changed

* Improved readability of example code

## [v0.3.2]

**Until v0.3.1:** Variables, functions and types were implicitly declared.
Expand Down
7 changes: 4 additions & 3 deletions examples/hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
code.append(C.sysinclude("stdio.h"))
code.append(C.blank())
char_ptr_type = C.type("char", pointer=True)
code.append(C.declaration(C.function("main", "int", params=[C.variable("argc", "int"),
C.variable("argv", char_ptr_type, pointer=True)
])))
code.append(C.declaration(C.function("main", "int",
params=[C.variable("argc", "int"),
C.variable("argv", char_ptr_type, pointer=True)
])))
main_body = C.block()
main_body.append(C.statement(C.func_call("printf", C.str_literal(r"Hello World\n"))))
main_body.append(C.statement(C.func_return(0)))
Expand Down
7 changes: 4 additions & 3 deletions examples/hello_world_styled.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
code.append(C.sysinclude("stdio.h"))
code.append(C.blank())
char_ptr_type = C.type("char", pointer=True)
code.append(C.declaration(C.function("main", "int", params=[C.variable("argc", "int"),
C.variable("argv", char_ptr_type, pointer=True)
])))
code.append(C.declaration(C.function("main", "int",
params=[C.variable("argc", "int"),
C.variable("argv", char_ptr_type, pointer=True)
])))
main_body = C.block()
main_body.append(C.statement(C.func_call("printf", C.str_literal(r"Hello World\n"))))
main_body.append(C.statement(C.func_return(0)))
Expand Down

0 comments on commit 308bbb6

Please sign in to comment.