Skip to content

added struct tags for all declared structs - #173

Merged
tylov merged 1 commit into
stclib:mainfrom
aalmkainzi:container-structs-tags
Aug 10, 2026
Merged

added struct tags for all declared structs #173
tylov merged 1 commit into
stclib:mainfrom
aalmkainzi:container-structs-tags

Conversation

@aalmkainzi

Copy link
Copy Markdown
Contributor

This is so that declare_* macros work in C23 without needing i_declared.

For example, this code did not work because structs like the _iter and _result structs do not have tags, and what happens is the two declarations declare the same typedef name, but two anonymous structs, so they are not compatible. adding a tag fixes it, because in C23 re-declaring the same struct with the same tag is allowed.

#include "stc/types.h"

// vec
declare_vec(Vec, int);

#define T Vec, int
#include "stc/vec.h"

// list
declare_list(List, int);

#define T List, int
#include "stc/list.h"

// queue

declare_queue(Queue, int);

#define T Queue, int
#include "stc/queue.h"

// hashset

declare_hashset(Set, int);

#define T Set, int
#include "stc/hashset.h"

// sortedset

declare_sortedset(SortedSet, int);

#define T SortedSet, int
#include "stc/sortedset.h"

@nikita-edel

Copy link
Copy Markdown

not allowing the same typdef on the same struct name in any standard annoys me so damn much, like this useless restriction destroys so much potential

@tylov

tylov commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Thanks a lot, and sorry about the late response!
I kind of knew about this requirement and recall/thought it worked without i_declared defined with C23, but haven't tested with it for a long while, but I was obviously wrong.

@tylov
tylov merged commit 87ff486 into stclib:main Aug 10, 2026
4 of 22 checks passed
@tylov

tylov commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Note: On Visual Studio with /std:clatest, you still have to define i_declared or add c_declared to your T definition, so for max portability I would still use:

declare_vec(Vec, int);
...
#define T Vec, int, c_declared
#include "stc/vec.h"

tylov added a commit that referenced this pull request Aug 10, 2026
… C23 without the need of defining i_declared). Thanks for the contribution from aalmkainzi.

- Minor cleanup in coroutine.
@nikita-edel

Copy link
Copy Markdown

Note: On Visual Studio with /std:clatest, you still have to define i_declared or add c_declared to your T definition, so for max portability I would still use:

declare_vec(Vec, int);
...
#define T Vec, int, c_declared
#include "stc/vec.h"

VS Latest doesnt support c23.

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.

4 participants