Skip to content

feat: declare a function of another file without a body - #46

Merged
Solype merged 3 commits into
mainfrom
feat/44-header-declaration
Nov 7, 2026
Merged

Solype merged 3 commits into
mainfrom
feat/44-header-declaration

Conversation

@Solype

@Solype Solype commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Part of #44. Based on #12 (fix/12-extern-local-symbol-conflict): merge that one first.

What changed

A program can be split into several files, compiled together with compiler -x lib.kr prog.kr. A file calls a function of another one through a header, a declaration without a body and without 외부:

정수를 반환하는 더하다(정수 가, 정수 나)

Left in #44: whether a header and its definition may be in one file (refused for now, SameSignature), and a single main checked by the compiler rather than by gcc.

How it was tested

  • cargo fmt --check, cargo clippy --all-targets: no warning.
  • cargo test: 1380 passed, 0 failed.
  • scripts/run_samples.sh: 62 passed, 0 failed.
  • scripts/missing.sh 44: 2 passed, 0 missing. lib.kr and prog.kr compile, link and the program returns 42; nm shows 더하다$int$int defined in lib.o and undefined in prog.o. A header and the definition in one file are refused.
  • run_samples.sh compiles one file at a time, so the CI does not cover two files yet.

Use of AI

Written by Claude Code at the request of the maintainer, from a design chosen together (외부 for the libc, a header for a function of another file).

A function declared without a body and without 외부 is a header: a Krc
function defined in another file, with the mangled symbol of its
definition. 외부 stays for the libc. Function gets an `external` field,
and the symbol is chosen from it instead of from the missing body.

With several files, a file no longer needs its own main: the linker
reports a missing or a second one. The language design describes
headers and several files.

Part of #44
Base automatically changed from fix/12-extern-local-symbol-conflict to main November 7, 2026 23:13
@Solype
Solype merged commit 7f4ef93 into main Nov 7, 2026
1 check passed
@Solype Solype linked an issue Nov 7, 2026 that may be closed by this pull request
6 tasks
@Solype
Solype deleted the feat/44-header-declaration branch November 7, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Language: header declaration (a function of another file)

1 participant