macro params struct pass.

This commit is contained in:
ed committed 2026-08-25 15:48:56 -04:00
1 parent c8b6acbc08
commit 6922d52b5e
23 files changed
+925

No files matched your search

+1
View File
@@ -29,4 +29,5 @@ Example of the note shape (single spine, no branches): [[archive/threads/How to
- [[archive/threads/rianflo]]
- [[archive/threads/simplex_fx]]
- [[archive/threads/valigo]]
- [[archive/threads/vkrajacic]]
- [[archive/threads/winning_tactic]]
@@ -0,0 +1,43 @@
---
title: "@vkrajacic Nice - when you combine this with all the other tricks (arenas, stretchy buffers, strings with length, etc), C is a really nice language to use!"
type: archive
source: twitter
source_url: "https://x.com/DanielcHooper/status/1749857446179299815"
author: "Daniel Hooper"
handle: DanielcHooper
post_id: "1749857446179299815"
date: 2024-01-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic Nice - when you combine this with all the other tricks (arenas, stretchy buffers, strings with length, etc), C is a really nice language to use!"
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/DanielcHooper/status/1749857446179299815
- Author: Daniel Hooper (@DanielcHooper)
- Posted: 2024-01-23 18:11:40
## Branch
**1/** @DanielcHooper
@vkrajacic
Nice - when you combine this with all the other tricks (arenas, stretchy buffers, strings with length, etc), C is a really nice language to use!
**2/** @vkrajacic
@DanielcHooper
Yes, C can almost feel like an entirely different language once you develop your own base technical layer.
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,37 @@
---
title: "@vkrajacic Neat!"
type: archive
source: twitter
source_url: "https://x.com/MrJayLC/status/1749843481822900718"
author: "John"
handle: MrJayLC
post_id: "1749843481822900718"
date: 2024-01-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic Neat!"
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/MrJayLC/status/1749843481822900718
- Author: John (@MrJayLC)
- Posted: 2024-01-23 17:16:11
## Branch
**1/** @MrJayLC
@vkrajacic
Neat!
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,37 @@
---
title: "@vkrajacic I love this!"
type: archive
source: twitter
source_url: "https://x.com/alurmanc/status/1749842429367185567"
author: "Alan Urmancheev"
handle: alurmanc
post_id: "1749842429367185567"
date: 2024-01-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic I love this!"
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/alurmanc/status/1749842429367185567
- Author: Alan Urmancheev (@alurmanc)
- Posted: 2024-01-23 17:12:00
## Branch
**1/** @alurmanc
@vkrajacic
I love this!
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,41 @@
---
title: "@vkrajacic Shouldn't it be TransformArguments?"
type: archive
source: twitter
source_url: "https://x.com/alurmanc/status/1749843270354538761"
author: "Alan Urmancheev"
handle: alurmanc
post_id: "1749843270354538761"
date: 2024-01-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic Shouldn't it be TransformArguments?"
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/alurmanc/status/1749843270354538761
- Author: Alan Urmancheev (@alurmanc)
- Posted: 2024-01-23 17:15:20
## Branch
**1/** @alurmanc
@vkrajacic
Shouldn't it be TransformArguments?
Parameters are at definition site, arguments are at the usage site. So, TransformParams seems logical. But you don't really have a very meaningful "definition site", so it might be better called TransformArguments. No?
I'm deeply confused :D
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,37 @@
---
title: "@vkrajacic How does default work? Do variable args bypass duplicate designator in initializer?"
type: archive
source: twitter
source_url: "https://x.com/endu06/status/1749930915566961088"
author: "wanderer"
handle: endu06
post_id: "1749930915566961088"
date: 2024-01-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic How does default work? Do variable args bypass duplicate designator in initializer?"
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/endu06/status/1749930915566961088
- Author: wanderer (@endu06)
- Posted: 2024-01-23 23:03:37
## Branch
**1/** @endu06
@vkrajacic
How does default work? Do variable args bypass duplicate designator in initializer?
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,37 @@
---
title: "@vkrajacic Very cool! Designated initializers is one thing I wish c++ had."
type: archive
source: twitter
source_url: "https://x.com/luis_reyes_x/status/1749940314951893348"
author: "Luis Reyes"
handle: luis_reyes_x
post_id: "1749940314951893348"
date: 2024-01-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic Very cool! Designated initializers is one thing I wish c++ had."
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/luis_reyes_x/status/1749940314951893348
- Author: Luis Reyes (@luis_reyes_x)
- Posted: 2024-01-23 23:40:58
## Branch
**1/** @luis_reyes_x
@vkrajacic
Very cool! Designated initializers is one thing I wish c++ had. C also lets you do a similar thing with arrays to initialize certain elements
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,46 @@
---
title: "The only problem here is that you cannot do this in a header file that is going to be included within a C++ source file..."
type: archive
source: twitter
source_url: "https://x.com/falco_girgis/status/1750088968681750741"
author: "Falco Girgis"
handle: falco_girgis
post_id: "1750088968681750741"
date: 2024-01-24
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "The only problem here is that you cannot do this in a header file that is going to be included within a C++ source file..."
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/falco_girgis/status/1750088968681750741
- Author: Falco Girgis (@falco_girgis)
- Posted: 2024-01-24 09:31:39
## Branch
**1/** @falco_girgis
The only problem here is that you cannot do this in a header file that is going to be included within a C++ source file... However, what you can do is macro out the compound literal and provide a C++20 temporary object initializer with slightly different syntax if __cplusplus is defined..
**2/** @vkrajacic
@falco_girgis
Yeah, I haven't tested that because my codebase is purely C nowadays.
I'm not concerned about compatibility with C++. I understand that this is not always a choice, especially when working with a codebase you didn't start.
**3/** @falco_girgis
Tbh, I've never encountered a scenario with supporting C++ where you couldn't still pull all the tricks like this with modern C, if you are willing to invest in the infrastructure... That includes using _Generic() switches, which aren't supported in C++... I have a macro layer which you use to declare each type and its associated call which will compile to a _Generic statement in C or... a to C++20 anonymous generic lambda doing a series of compile-time conditionals on the generic type argument and mapping it to the appropriate logic based on its type... Yeah, it's a shitshow, but you write it once and it just works. lol. https://github.com/gyrovorbis/libgimbal/blob/79722a270d2a80651d08eb0158e803c9e4a2de6e/lib/api/gimbal/utils/gimbal_scanner.h#L366
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,39 @@
---
title: "@vkrajacic C++ functor method"
type: archive
source: twitter
source_url: "https://x.com/JLakness/status/1955779942689726670"
author: "John Lakness"
handle: JLakness
post_id: "1955779942689726670"
date: 2025-08-13
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic C++ functor method"
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/JLakness/status/1955779942689726670
- Author: John Lakness (@JLakness)
- Posted: 2025-08-13 23:54:09
## Branch
**1/** @JLakness
@vkrajacic
C++ functor method
![](https://pbs.twimg.com/media/GyRSR0za4AMaVLN?format=png&name=orig)
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,37 @@
---
title: "@vkrajacic this one is amazing to be honest"
type: archive
source: twitter
source_url: "https://x.com/YehorAvramenko/status/1955676990754934991"
author: "Yehor Avramenko"
handle: YehorAvramenko
post_id: "1955676990754934991"
date: 2025-08-13
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic this one is amazing to be honest"
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/YehorAvramenko/status/1955676990754934991
- Author: Yehor Avramenko (@YehorAvramenko)
- Posted: 2025-08-13 17:05:03
## Branch
**1/** @YehorAvramenko
@vkrajacic
this one is amazing to be honest
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,37 @@
---
title: "@vkrajacic Haven't gotten to this place, I gotta keep pushing forward till I get gigachad levels like you"
type: archive
source: twitter
source_url: "https://x.com/gretzky00/status/1955713762163409316"
author: "Jajanken"
handle: gretzky00
post_id: "1955713762163409316"
date: 2025-08-13
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic Haven't gotten to this place, I gotta keep pushing forward till I get gigachad levels like you"
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/gretzky00/status/1955713762163409316
- Author: Jajanken (@gretzky00)
- Posted: 2025-08-13 19:31:10
## Branch
**1/** @gretzky00
@vkrajacic
Haven't gotten to this place, I gotta keep pushing forward till I get gigachad levels like you
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,37 @@
---
title: "@vkrajacic This is soo good, I did it in Typescript as well and my life is easier now........"
type: archive
source: twitter
source_url: "https://x.com/heyitsvaishnav/status/1955715131293491311"
author: "Vaishnav Mhetre"
handle: heyitsvaishnav
post_id: "1955715131293491311"
date: 2025-08-13
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic This is soo good, I did it in Typescript as well and my life is easier now........"
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/heyitsvaishnav/status/1955715131293491311
- Author: Vaishnav Mhetre (@heyitsvaishnav)
- Posted: 2025-08-13 19:36:37
## Branch
**1/** @heyitsvaishnav
@vkrajacic
This is soo good, I did it in Typescript as well and my life is easier now........
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,39 @@
---
title: "@vkrajacic really cool, but this doesn't mean c is a good or nice language in modern standards."
type: archive
source: twitter
source_url: "https://x.com/peach2k2/status/1955706381077496306"
author: "« 2k2 »"
handle: peach2k2
post_id: "1955706381077496306"
date: 2025-08-13
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic really cool, but this doesn't mean c is a good or nice language in modern standards."
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/peach2k2/status/1955706381077496306
- Author: « 2k2 » (@peach2k2)
- Posted: 2025-08-13 19:01:51
## Branch
**1/** @peach2k2
@vkrajacic
really cool, but this doesn't mean c is a good or nice language in modern standards.
it just means you can hack it to have basic functionality you'd expect from most other languages out of the box
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,144 @@
---
title: "@vkrajacic @CaptainKraft Am i the only one who thinks this is terrible? Its incredibly confusing to read and you cant see what parameters you miss, the header file is a lot more complex to read too."
type: archive
source: twitter
source_url: "https://x.com/EskilSteenberg/status/1955882027997069711"
author: "Eskil Steenberg"
handle: EskilSteenberg
post_id: "1955882027997069711"
date: 2025-08-14
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic @CaptainKraft Am i the only one who thinks this is terrible? Its incredibly confusing to read and you cant see what parameters you miss, the header file is a lot more complex to read too."
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/EskilSteenberg/status/1955882027997069711
- Author: Eskil Steenberg (@EskilSteenberg)
- Posted: 2025-08-14 06:39:48
## Branch
**1/** @EskilSteenberg
@vkrajacic @CaptainKraft
Am i the only one who thinks this is terrible? Its incredibly confusing to read and you cant see what parameters you miss, the header file is a lot more complex to read too. You lose the WYIWYG nature of C. If you want this kind of ”clever” syntax why not use C++?
**2/** @vkrajacic
It might be confusing the first time you encounter it, because it's not used often in C codebases. But that's true for a lot of things in C, since you often have to invent better solutions (like strings or memory arenas).
As I said, I use this sparingly, but where it is used, it has always provided a better API. Ideally, I strive for ZII, so I don’t need a way of setting default values and can use a designated initializers to override when needed. That’s the best case scenario, and most of my base layer functions work like that.
This will not work with C++, as far as I know, because they messed up designated initializers. There are probably other ways to do it there, but I don’t want C++.
**3/** @EskilSteenberg
@vkrajacic @CaptainKraft
I think its confusing every time you see it. If i read:
function(x, .param = 42);
The code does not communicate, what this function can do or if I'm missing a parameter.
You also have to read all parameters in the function with one more level of indirection and thats slow.
**4/** @vkrajacic
I don’t see how this is different from:
void PushTransform(Rect rect, TransformParams params);
or
void PushTransform(Rect rect, Vec2 pivot, Dim2 scale, f32 angle, b32 clip);
You still need to read the header (or docs) to see what each argument does, and how to pass in some default value to ignore it.
For what it’s worth, the pattern I use more commonly is to separate functions that take extra parameters:
void PushTransform(Rect rect);
void PushTransformEx(Rect rect, Vec2 pivot, Dim2 scale, f32 angle, b32 clip);
The first one just calls the Ex version with some reasonable defaults.
This works fine in most cases, but if you have a lot of arguments, you either have to make many such function permutations or force the caller to pass in all arguments, even the ones they don’t care about.
**5/** @EskilSteenberg
@vkrajacic @CaptainKraft
I don't like:
void func(StructOfInputs params);
You are hiding the input, and you are forcing a memory layout. I don't even like small structs like Dim2, and Rect because they force the caller to adopt the structures of the callee. Don't force me to live in your world.
**6/** @vkrajacic
There’s no hiding of any kind, it’s a public POD struct.
The "Don’t force me to live in your world" argument can only be made for library vendors, which I’m not. This is my codebase, and I control it. Vectors and rects are abstractions with their own API functions that operate on them. Manually passing individual components is just not worth it.
If you really wanted, you could add multiple versions of functions, which I sometimes do:
RectCreate(Vec2 min, Vec2 max);
vs
RectCreate(f32 minX, f32 minY, f32 maxX, f32 maxY);
Yes, it enforces memory layout, but that’s kind of the point of structs, bundling data that gets used together. And vectors are a prime example of that, especially in games and renderers, because they act as primitives and are ubiquitous throughout the code.
**7/** @vkrajacic
@EskilSteenberg @CaptainKraft
Another example in my codebase would be length based strings. I’ve built the whole API on top of those. I don’t want to go around passing char *value, int length. The point of that abstraction is that I don’t have to do that.
**8/** @nicbarkeragain
@vkrajacic @EskilSteenberg @CaptainKraft
I don't think I could ever go back to writing C with naked arrays / strings. It's such a small cost to pass length (and capacity) around, it's so simple and makes C feel like a different language.
**9/** @daniel_collin
@nicbarkeragain @vkrajacic @EskilSteenberg @CaptainKraft
Yeah, I'm building a whole new C codebase and I'm having a String type for sure. Makes things just nicer.
**10/** @NotAttained
@EskilSteenberg @vkrajacic @CaptainKraft
What is the alternative though if it’s a big struct, do you just manually type out the parameters each time, even if they are largely the same?
**11/** @EskilSteenberg
@NotAttained @vkrajacic @CaptainKraft
YES! Having to declare a variable of the struct an then assigning every member is far more cumbersome and error prone.
**12/** @vkrajacic
It is if you're typing them all out. But the whole point of the post was about when you DON'T want to do that.
Ideally, you'd have them zero initialized or set with some default arguments, and then just override the ones you want, via designated initializer syntax.
At that point, it becomes less cumbersome and less error prone, because the defaults are already set up for you. You don’t have to write them again.
If you have lots of parameters, it's almost always the case that you don't need to set each one at the call site. If you only have a few, then a struct is unnecessary.
**13/** @vkrajacic
@EskilSteenberg @NotAttained @CaptainKraft
For instance, old win APIs often take a long list of parameters. In many cases, you only need a couple of options and pass 0 to everything else, e.g. NtQueryDirectoryFile.
![](https://pbs.twimg.com/media/GyVoVhQWcAUqchq?format=png&name=orig)
**14/** @Karyuutensei
@vkrajacic @EskilSteenberg @NotAttained @CaptainKraft
To be honest, function parameters get confusing beyond 2-3. Named parameters are much better.
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,37 @@
---
title: "@vkrajacic Honestly I don't know what I am looking at anymore"
type: archive
source: twitter
source_url: "https://x.com/FrawaMudi/status/1955896975330582796"
author: "Frawa mudi"
handle: FrawaMudi
post_id: "1955896975330582796"
date: 2025-08-14
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic Honestly I don't know what I am looking at anymore"
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/FrawaMudi/status/1955896975330582796
- Author: Frawa mudi (@FrawaMudi)
- Posted: 2025-08-14 07:39:12
## Branch
**1/** @FrawaMudi
@vkrajacic
Honestly I don't know what I am looking at anymore
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,37 @@
---
title: "@vkrajacic Bravo!"
type: archive
source: twitter
source_url: "https://x.com/emh203/status/1955793903548031362"
author: "Eli Hughes"
handle: emh203
post_id: "1955793903548031362"
date: 2025-08-14
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic Bravo!"
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/emh203/status/1955793903548031362
- Author: Eli Hughes (@emh203)
- Posted: 2025-08-14 00:49:38
## Branch
**1/** @emh203
@vkrajacic
Bravo!
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,37 @@
---
title: "@vkrajacic Let's go 10k likes."
type: archive
source: twitter
source_url: "https://x.com/etozheya42/status/1955797197108236796"
author: "Hello"
handle: etozheya42
post_id: "1955797197108236796"
date: 2025-08-14
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic Let's go 10k likes."
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/etozheya42/status/1955797197108236796
- Author: Hello (@etozheya42)
- Posted: 2025-08-14 01:02:43
## Branch
**1/** @etozheya42
@vkrajacic
Let's go 10k likes.
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,37 @@
---
title: "@vkrajacic instantly rewriting everything"
type: archive
source: twitter
source_url: "https://x.com/quantized_state/status/1955925511575888092"
author: "state"
handle: quantized_state
post_id: "1955925511575888092"
date: 2025-08-14
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic instantly rewriting everything"
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/quantized_state/status/1955925511575888092
- Author: state (@quantized_state)
- Posted: 2025-08-14 09:32:35
## Branch
**1/** @quantized_state
@vkrajacic
instantly rewriting everything
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,37 @@
---
title: "@vkrajacic This is so cool!"
type: archive
source: twitter
source_url: "https://x.com/siddhantCodes/status/1955847027704627626"
author: "siddhant kumar"
handle: siddhantCodes
post_id: "1955847027704627626"
date: 2025-08-14
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic This is so cool!"
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/siddhantCodes/status/1955847027704627626
- Author: siddhant kumar (@siddhantCodes)
- Posted: 2025-08-14 04:20:43
## Branch
**1/** @siddhantCodes
@vkrajacic
This is so cool!
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,37 @@
---
title: "@vkrajacic I may be just one like, but together we build the whole 10k."
type: archive
source: twitter
source_url: "https://x.com/k00lagin/status/1956460989324710205"
author: "Vsevolod Kulagin"
handle: k00lagin
post_id: "1956460989324710205"
date: 2025-08-15
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic I may be just one like, but together we build the whole 10k."
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/k00lagin/status/1956460989324710205
- Author: Vsevolod Kulagin (@k00lagin)
- Posted: 2025-08-15 21:00:23
## Branch
**1/** @k00lagin
@vkrajacic
I may be just one like, but together we build the whole 10k.
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,37 @@
---
title: "@vkrajacic thank you!"
type: archive
source: twitter
source_url: "https://x.com/CarloIlCugino/status/2005479710604894610"
author: "CARLO"
handle: CarloIlCugino
post_id: "2005479710604894610"
date: 2025-12-29
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "@vkrajacic thank you!"
in_reply_to: ""
parent_post_id: "1749816169736073295"
---
## Source
- URL: https://x.com/CarloIlCugino/status/2005479710604894610
- Author: CARLO (@CarloIlCugino)
- Posted: 2025-12-29 03:23:17
## Branch
**1/** @CarloIlCugino
@vkrajacic
thank you!
## Related
- Spine: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]
@@ -0,0 +1,42 @@
---
title: "C macro approach to using optional / default / named function params, using struct designated initializers."
type: archive
source: twitter
source_url: "https://x.com/vkrajacic/status/1749816169736073295"
author: "Vjekoslav Krajačić"
handle: vkrajacic
post_id: "1749816169736073295"
date: 2024-01-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- vkrajacic
description: "C macro approach to using optional / default / named function params, using struct designated initializers."
in_reply_to: ""
---
## Source
- URL: https://x.com/vkrajacic/status/1749816169736073295
- Author: Vjekoslav Krajačić (@vkrajacic)
- Posted: 2024-01-23 15:27:39
## Thread
**1/** @vkrajacic
C macro approach to using optional / default / named function params, using struct designated initializers.
Mandatory values are passed first as standard function params (rect in the example).
Especially useful when a zero value can be made a valid value.
![](https://pbs.twimg.com/media/GEiYTeEbgAAXuRo?format=jpg&name=orig)
Branches: [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2024-01-23-alurmanc-i-love-this]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2024-01-23-alurmanc-shouldnt-it-be-transformarguments-parameters-are]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2024-01-23-MrJayLC-neat]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2024-01-23-DanielcHooper-nice-when-you-combine-this-with-all-the-other]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2024-01-23-endu06-how-does-default-work-do-variable-args-bypass]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2024-01-23-luis_reyes_x-very-cool-designated-initializers-is-one-thing-i]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2024-01-24-falco_girgis-the-only-problem-here-is-that-you-cannot-do-this]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2025-08-13-YehorAvramenko-this-one-is-amazing-to-be-honest]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2025-08-13-peach2k2-really-cool-but-this-doesnt-mean-c-is-a-good-or]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2025-08-13-gretzky00-havent-gotten-to-this-place-i-gotta-keep-pushing]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2025-08-13-heyitsvaishnav-this-is-soo-good-i-did-it-in-typescript-as-well]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2025-08-13-JLakness-c-functor-method]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2025-08-14-emh203-bravo]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2025-08-14-etozheya42-lets-go-10k-likes]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2025-08-14-siddhantCodes-this-is-so-cool]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2025-08-14-EskilSteenberg-am-i-the-only-one-who-thinks-this-is-terrible-its]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2025-08-14-FrawaMudi-honestly-i-dont-know-what-i-am-looking-at-anymore]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2025-08-14-quantized_state-instantly-rewriting-everything]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2025-08-15-k00lagin-i-may-be-just-one-like-but-together-we-build-the]], [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named/2025-12-29-CarloIlCugino-thank-you]]
**2/** @pATjako
@vkrajacic
I started experimenting with that in my imgui as well, it is kinda neat, also you can make the same code work for C & C++ (with some limitation in argument ordering)
+12
View File
@@ -0,0 +1,12 @@
---
title: vkrajacic
type: note
draft: false
description: Archived threads by vkrajacic.
tags:
- archive
- twitter
- vkrajacic
---
- [[archive/threads/vkrajacic/2024-01-23-c-macro-approach-to-using-optional-default-named]]