OpenGL and Vulkan examples; ptr(int)/int(ptr); trailing commas in calls; drop .fn hint

- examples/opengl.fch: OpenGL 3.3 core, shaders, VAO/VBO, a spinning triangle (checked offscreen)
- examples/vulkan.fch: instance, GPUs with properties/memory/queues, logical device and queue
- ptr(n) and int(p) conversions for C APIs that pass offsets as pointers
- .ptr works on string literals; a comma after the last call argument is allowed
- a missing header included by an imported header is now named in the error
- the old .fn extension hint is gone (Finch is new, there are no old files)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nexoniarz 2026-10-08 19:37:34 +02:00
commit 8497251dc5
22 changed files with 357 additions and 26 deletions

View file

@ -341,8 +341,14 @@ CImports importHeaders(const std::vector<Import> &imports, const std::vector<std
if (clang_getDiagnosticSeverity(d) >= CXDiagnostic_Error) {
std::string msg = str(clang_getDiagnosticSpelling(d));
clang_disposeDiagnostic(d);
if (msg.find("file not found") != std::string::npos)
failAt(im.pos.file, im.pos.line, im.pos.col, "can't find the C header '" + im.path + "'");
if (msg.find("file not found") != std::string::npos) {
// "'GL/gl.h' file not found": it may be a header that this one includes
std::string missing = msg.substr(1, msg.find('\'', 1) - 1);
if (missing == im.path)
failAt(im.pos.file, im.pos.line, im.pos.col, "can't find the C header '" + im.path + "'");
failAt(im.pos.file, im.pos.line, im.pos.col, "can't find the C header '" + missing + "', which '" + im.path +
"' includes (is its library's development package installed?)");
}
failAt(im.pos.file, im.pos.line, im.pos.col, "C header '" + im.path + "' has an error: " + msg);
}
clang_disposeDiagnostic(d);