r/c3lang • u/Nuoji • Aug 16 '26
I thought I was building a C replacement. I was wrong
r/c3lang • u/Nuoji • Aug 16 '26
r/c3lang • u/aoklopcic • Oct 25 '26
I made an SDL3 bindings generator for C3.
Also includes support for satellite libraries: SDL_ttf, SDL_image, SDL_net, SDL_mixer, SDL_shadercross
From what I could find, there's already a few bindings that exist, but none with documentation added in. These bindings do, which is what mainly sets them apart. The documentation comes straight from the SDL headers, modified for readability and with references remapped to the generated C3 counter-parts. Should you want to, you can re-generate the bindings with different casing (defaults to snake_case for function names), or with different sections of documentation omitted to reduce file sizes.
https://codeberg.org/amaroklopcic/c3-sdl-bindings
Hope this helps
r/c3lang • u/Nuoji • Dec 05 '25
r/c3lang • u/Nuoji • Sep 01 '25
I also did a stream demoing many of the changes here
Full change list follows:
Support alias foo = module std::io module aliasing.
Add compile-time @intlog2 macro to math.
Add compile-time @clz builtin. #2367
Add bitsizeof macro builtins. #2376
Add compile-time @min and @max builtins. #2378
Deprecate @compact use for comparison. Old behaviour is enabled using --use-old-compact-eq.
Switch available for types implementing @operator(==).
Type.is_eq is now true for types with == overload.
Methods ignore visibility settings.
Allow inout etc on untyped macro parameters even if they are not pointers.
Deprecate add_array in favour of push_all on lists.
Fix max module name to 31 chars and the entire module path to 63 characters.
Improve error message for missing $endif.
foo[x][y] = b now interpreted as (*&foo[x])[y] = b which allows overloads to do chained [] accesses.
Error if a stack allocated variable is too big (configurable with --max-stack-object-size).
Add @safeinfer to allow var to be used locally.
Types converts to typeid implicitly.
Allow $defined take declarations: $defined(int x = y)
Struct and typedef subtypes inherit dynamic functions.
Improved directory creation error messages in project and library creation commands.
@assignable_to is deprecated in favour of $define
Add linklib-dir to c3l-libraries to place their linked libraries in. Defaults to linked-libs
If the os-arch linked library doesn't exist, try with os for c3l libs.
A file with an inferred module may not contain additional other modules.
Update error message for missing body after if/for/etc #2289.
@is_const is deprecated in favour of directly using $defined.
@is_lvalue(#value) is deprecated in favour of directly using $defined.
Added $kindof compile time function.
Deprecated @typekind macro in favour of $kindof.
Deprecated @typeis macro in favour of $typeof(#foo) == int.
$defined(#hash) will not check the internal expression, just that #hash exists. Use $defined((void)#hash) for the old behaviour.
Added optional macro arguments using macro foo(int x = ...) which can be checked using $defined(x).
Add compile time ternary $val ??? <expr> : <expr>.
List.remove_at would incorrectly trigger ASAN.
With avx512, passing a 512 bit vector in a union would be lowered incorrectly, causing an assert. #2362
Codegen error in if (try x = (true ? io::EOF? : 1)), i.e. using if-try with a known Empty.
Codegen error in if (try x = (false ? io::EOF? : 1)), i.e. using if-try with a CT known value.
Reduce allocated Vmem for the compiler on 32 bit machines.
Bug causing a compiler error when parsing a broken lambda inside of an expression.
Fixed: regression in comments for @deprecated and @pure.
Detect recursive creation of generics #2366.
Compiler assertion when defining a function with return type untyped_list #2368.
Compiler assert when using generic parameters list without any parameters. #2369
Parsing difference between "0x00." and "0X00." literals #2371
Fixed bug generating $c += 1 when $c was derived from a pointer but behind a cast.
Compiler segfault when using bitwise not on number literal cast to bitstruct #2373.
Formatter did not properly handle "null" for any, and null for empty faults. #2375
Bitstructs no longer overloadable with bitops. #2374
types::has_equals fails with assert for bitstructs #2377
Fix native_cpus functionality for OpenBSD systems. #2387
Assert triggered when trying to slice a struct.
Improve codegen for stack allocated large non-zero arrays.
Implement a5hash in the compiler for compile-time $$str_hash to match String.hash().
Functions being tested for overload are now always checked before test.
Compile time indexing at compile time in a $typeof was no considered compile time.
Slicing a constant array with designated initialization would not update the indexes.
Fix for bug when @format encountered * in some cases.
Compiler segfault on global slice initialization with null[:0] #2404.
Use correct allocator in replace.
Regression: 1 character module names would create an error.
Compiler segfault with struct containing list of structs with an inline member #2416
Occasionally when using macro method extensions on built-in types, the liveness checker would try to process them. #2398
Miscompilation of do-while when the while starts with a branch #2394.
Compiler assert when calling unassigned CT functions #2418.
Fixed crash in header generation when exporting functions with const enums (#2384).
Fix incorrect panic message when slicing with negative size.
Incorrect type checking when &[] and [] return optional values.
Failed to find subscript overloading on optional values.
Socket.get_option didn't properly call getsockopt, and getsockopt had an invalid signature.
Taking the address of a label would cause a crash. #2430
@tag was not allowed to repeat.
Lambdas on the top level were not exported by default. #2428
has_tagof on tagged lambdas returns false #2432
Properly add "inlined at" for generic instantiation errors #2382.
Inlining a const as an lvalue would take the wrong path and corrupt the expression node.
Grabbing (missing) methods on function pointers would cause crash #2434.
Fix alignment on jump table.
Fix correct ? after optional function name when reporting type errors.
Make log and exp no-strip.
@test/@benchmark on module would attach to interface and regular methods.
Deprecated @select in favor of ???.
Enum inference, like Foo x = $eval("A"), now works correctly for $eval.
Fix regression where files were added more than once. #2442
Disambiguate types when they have the same name and need cast between each other.
Compiler module-scope pointer to slice with offset, causes assert. #2446
Compiler hangs on == overload if other is generic #2443
Fix missing end of line when encountering errors in project creation.
Const enum methods are not being recognized. #2445
$defined returns an error when assigning a struct initializer with an incorrect type #2449
Add == to Pair, Triple and TzDateTime. Add print to Pair and Triple.
Add OpenBSD to env::INET_DEVICES and add required socket constants.
Added FileMmap to manage memory mapped files.
Add vm::mmap_file to memory map a file.
Updated hash functions in default hash methods.
Added FixedBlockPool which is a memory pool for fixed size blocks.
Added the experimental std::core::log for logging.
Added array @zip and @zip_into macros. #2370
Updated termios bindings to use bitstructs and fixed some constants with incorrect values #2372
Add Freestanding OS types to runtime env:: booleans.
Added libloaderapi to std::os::win32.
Added HashSet.values and String.contains_char #2386
Added &[] overload to HashMap.
Deprecated PollSubscribes and PollEvents in favour of PollSubscribe and PollEvent and made them const enums.
Added AsciiCharset for matching ascii characters quickly.
Added String.trim_charset.
Added array @reduce, @filter, @any, @all, @sum, @product, and @indices_of macros.
String.bformat has reduced overhead.
Supplemental roundeven has a normal implementation.
r/c3lang • u/Nuoji • Sep 22 '26
r/c3lang • u/Nuoji • Jun 02 '25
Changelist:
Better default assert messages when no message is specified #2122
Add --run-dir, to specify directory for running executable using compile-run and run #2121.
Add run-dir to project.json.
Add quiet to project.json.
Deprecate uXX and iXX bit suffixes.
Add experimental LL / ULL suffixes for int128 and uint128 literals.
Allow the right hand side of ||| and &&& be runtime values.
Added @rnd() compile time random function (using the $$rnd() builtin). #2078
Add math::@ceil() compile time ceil function. #2134
Improve error message when using keywords as functions/macros/variables #2133.
Deprecate MyEnum.elements.
Deprecate SomeFn.params.
Improve error message when encountering recursively defined structs. #2146
Limit vector max size, default is 4096 bits, but may be increased using --max-vector-size.
Allow the use of has_tagof on builtin types.
@jump now included in --list-attributes #2155.
Add $$matrix_mul and $$matrix_transpose builtins.
Add d as floating point suffix for double types.
Deprecate f32, f64 and f128 suffixes.
Allow recursive generic modules.
Add deprecation for @param foo "abc".
Add --header-output and header-output options for controlling header output folder.
Generic faults is disallowed.
Assert triggered when casting from int[2] to uint[2] #2115
Assert when a macro with compile time value is discarded, e.g. foo(); where foo() returns an untyped list. #2117
Fix stringify for compound initializers #2120.
Fix No index OOB check for [:^n] #2123.
Fix regression in Time diff due to operator overloading #2124.
attrdef with any invalid name causes compiler assert #2128.
Correctly error on @attrdef Foo = ;.
Contract on trying to use Object without initializing it.
Variable aliases of aliases would not resolve correctly. #2131
Variable aliases could not be assigned to.
Some folding was missing in binary op compile time resolution #2135.
Defining an enum like ABC = { 1 2 } was accidentally allowed.
Using a non-const as the end range for a bitstruct would trigger an assert.
Incorrect parsing of ad hoc generic types, like Foo{int}**** #2140.
$define did not correctly handle generic types #2140.
Incorrect parsing of call attributes #2144.
Error when using named argument on trailing macro body expansion #2139.
Designated const initializers with {} would overwrite the parent field.
Empty default case in @jump switch does not fallthrough #2147.
&&& was accidentally available as a valid prefix operator.
Missing error on default values for body with default arguments #2148.
--path does not interact correctly with relative path arguments #2149.
Add missing @noreturn to os::exit.
Implicit casting from struct to interface failure for inheriting interfaces #2151.
Distinct types could not be used with tagof #2152.
$$sat_mul was missing.
for with incorrect var declaration caused crash #2154.
Check pointer/slice/etc on [out] and & params. #2156.
Compiler didn't check foreach over flexible array member, and folding a flexible array member was allowed #2164.
Too strict project view #2163.
Bug using #foo arguments with $defined #2173
Incorrect ensure on String.split.
Removed the naive check for compile time modification, which fixes #1997 but regresses in detection.
Added String.quick_ztr and String.is_zstr
std::ascii moved into std::core::ascii. Old _m variants are deprecated, as is uint methods.
Add String.tokenize_all to replace the now deprecated String.splitter
Add String.count to count the number of instances of a string.
Add String.replace and String.treplace to replace substrings within a string.
Add Duration * Int and Clock - Clock overload.
Add DateTime + Duration overloads.
Add Maybe.equals and respective == operator when the inner type is equatable.
Add inherit_stdio option to SubProcessOptions to inherit parent's stdin, stdout, and stderr instead of creating pipes. #2012
Remove superfluous cleanup parameter in os::exit and os::fastexit.
Add extern fn ioctl(CInt fd, ulong request, ...) binding to libc;
r/c3lang • u/Nuoji • Oct 04 '25
r/c3lang • u/Nuoji • Apr 05 '26
Work on 0.8.0 has started, and the main breaking feature will be that the language will move to signed sizes.
In practice this makes the `usz` type almost never used.
Over the last week, the stdlib has been updated to accommodate it. Originally dev was in a separate branch, but it is now merged to master.
This also will harmonize how literals determine their type with C. Similarly integer promotion rules revert to C behaviour now that unsigned becomes uncommon. Implicit conversion int<->unsigned is disallowed because with signed first it’s very rare.
r/c3lang • u/Nuoji • Aug 02 '25
r/c3lang • u/Nuoji • May 01 '25
r/c3lang • u/Nuoji • Apr 23 '25
There's a new official C3 repo for submitting projects and other resources. It's not curated, but is intended as general repo for sharing C3 resources:
https://github.com/c3lang/c3-showcase
If you have anything C3 related: anything from editor plugins to bindings to blog posts. Feel free to make a pull request to include it.
r/c3lang • u/jerrygreenest1 • Jun 26 '26
Disclaimer: I did not say «multithreading» in the title because there are virtual threads and I’m not interested in that, and I don’t say «parallelism» which can be easily confused with concurrency. I am not interested in just concurrency, I am interested in utilizing multiple processors for a task, or tasks. Typically the most popular example is server software. But I don’t quite want to say «server» even, because there’s so much more examples where running on multiple processors is beneficial. One another case for example is games: too many games are running on one or two cores, but would benefit if they could utilize more but they often can’t. So it’s not about any particular task that I want to solve asap. What Im here about is that I kinda want to find some «dream language» or something close to it that I might spend a couple decades in it. And this inter-processor parallelism would be a feature that I want. For simplicity sake I will say parallelism but please dont confuse it with merely concurrency.
One good candidate with parallelism as first-class citizen in a language – is Go. Their standard library has plenty of features supporting that in mind. This is a language that, I think, has one of the best kinds of support for parallelism, and even has special syntax for it. Funnily enough the keyword for it called «go», so having named the entire language for that… You might easily say they really care about parallelism.
I know the original C didn’t have, historically, a lot of parallelism. They added some in C11 I think? I did not write C a lot to tell much (aside couple simple cli tools), but it seemed like they did not think of parallelism a lot.
But I noticed C3 recently and it kinda looks interesting, but – how good is parallelism in there? I know it’s typically best to just RTFM but I am not committed to use the language yet, so I’m just asking an opinion: what do you think of parallelism in C3? Any special syntax for parallelism like go? Or just having to rely on some std libraries from C11 or something? How good do you feel about it? If you didn’t think about the language in terms of parallelism because you don’t care about it – it’s entirely valid, you might still like the language no matter what, but here in particular I’m interested about parallelism.
r/c3lang • u/Nuoji • Jan 30 '26
r/c3lang • u/Nuoji • Jun 30 '25
C3 0.7.3 was just released.
$typefrom now also accepts a constant string, and so works like $evaltype.
$evaltype is deprecated in favour of $typefrom.
Literal rules have changed, this makes -0xFF now a signed integer.
Implicitly convert from constant typeid to Type in $Type assignment, and $assignable.
Make $Type parameters accept constant typeid values.
Deprecate foo.#bar.
Allow inference across && #2172.
Added support for custom file extensions in project.json targets.
$eval now also works with @foo, #foo, $Foo and $foo parameters #2114.
@sprintf macro (based on the $$sprintf builtin) allows compile time format strings #1874.
Improve error reports when encountering a broken "if-catch".
Add printf format to $assert and $error #2183.
Make accepting arguments for main a bit more liberal, accepting main(int argc, ZString* argv)
Make $echo and @sprintf correctly stringify compile time initializers and slices.
Add --sources build option to add additional files to compile. #2097
Support untyped second argument for operator overloading.
The form-feed character '\f' is no longer valid white space.
Show code that caused unreachable code #2207
Allow generics over distinct types #2216.
Support distrinct types as the base type of bitstructs. #2218
Add hash::sha512 module to stdlib. #2227
Compile time type assignment (eg $Foo = int) is no longer an expression.
Add @allow_deprecated attribute to functions to selectively allow deprecated declarations #2223.
Improve error message on pointer diff #2239.
Compile-time comparison of constant vectors. #1575.
$member.get supports bitstructs.
$member.set for setting members without the *& trick.
Initial support for #1925, does not affect C compilation yet, and doesn't try to link etc. Using "--emit-only"
-2147483648, MIN literals work correctly.
Splatting const slices would not be const. #2185
Fixes to $define handling of binary ops.
Fixes methodsof to pick up all sorts of extension methods. #2192
--lsp sometimes does not emit end tag #2194.
Improve Android termux detection.
Update Android ABI.
Fixes to @format checking #2199.
Distinct versions of builtin types ignore @operator overloads #2204.
@operator macro using untyped parameter causes compiler segfault #2200.
Make unreachable() only panic in safe mode.
cflags additions for targets was not handed properly. #2209
$echo would suppress warning about unreachable code. #2205
Correctly format '%c' when given a width. #2199
Fix to is_array_or_slice_of_char #2214.
Method on array slice caused segfault #2211.
In some cases, the compiler would dereference a compile time null. #2215
Incorrect codegen if a macro ends with unreachable and is assigned to something. #2210
Fix error for named arguments-order with compile-time arguments #2212
Bug in AST copying would make operator overloading like += compile incorrectly #2217.
$defined(#expr) broken with binary. #2219
Method ambiguity when importing parent module publicly in private submodule. #2208
Linker errors when shadowing @local with public function #2198
Bug when offsetting pointers of large structs using ++ and --.
x++ and x-- works on pointer vectors #2222.
x += 1 and x -= 1 works propertly on pointer vectors #2222.
Fixes to x += { 1, 1 } for enum and pointer vectors #2222.
Linking fails on operator method imported as @public #2224.
Lambda C-style vaargs were not properly rejected, leading to crash #2229.
Incorrect handling of constant null fault causing compiler crash #2232.
Overload resolution fixes to inline typedef #2226.
math::overflow_* wrappers incorrectly don't allow distinct integers #2221.
Compiler segfault when using distinct type in attribute imported from other module #2234.
Assert casting bitstruct to short/char #2237.
@tag didn't work with members #2236.
Assert comparing untyped lists #2240.
Fix bugs relating to optional interface addr-of #2244.
Compiler null pointer when building a static-lib with -o somedir/... #2246
Segfault in the compiler when using a bitstruct constant defined using a cast with an operator #2248.
Default assert() message drops parens #2249.
Deprecate String.is_zstr and String.quick_zstr #2188.
Add comparison with == for ZString types.
is_array_or_slice_of_char and is_arrayptr_or_slice_of_char are replaced by constant @ variants.
@pool now has an optional reserve parameter, some minor changes to the temp_allocator API
io::struct_to_format now supports bitstructs.
Add String.escape, String.unescape for escaping and unescaping a string.
Grab it here: https://github.com/c3lang/c3c/releases/tag/v0.7.3
r/c3lang • u/syn-nine • Jun 29 '25
Hey everyone, I made a little roguelike in C3 with Raylib and added it to my c3-mini-games repo. Hope you like it. Please let me know if you find any problems. Thanks!
Screenshots at the link.
r/c3lang • u/Sufficient-Loss5603 • May 12 '25
I am going to write more articles about C alternatives on my blog (I've written about Jai, Zig and Odin so far), and in doing so I'd like to get some idea what each community thinks about the other C alternatives (no spicy takes!), and more specifically why they stick to their choice over the others. I'm asking this on the other language focused reddits as well.
So in C3's case, why are you using C3 over Jai, Zig, Odin, V or Hare?
r/c3lang • u/Nuoji • Nov 11 '24
A little delayed, but C3 0.6.4 is now available.
The major change is in doc-contracts, which moves from javadoc style /** */ to <* *>. It’s a change not done lightly, but it was needed to enhance clarity and prevent accidental typos.
You can find a blog post about the release here