Skip to content

Register extern struct/union symbols#314

Open
borup3 wants to merge 2 commits intoz-libs:mainfrom
borup3:register-extern-struct-union
Open

Register extern struct/union symbols#314
borup3 wants to merge 2 commits intoz-libs:mainfrom
borup3:register-extern-struct-union

Conversation

@borup3
Copy link
Contributor

@borup3 borup3 commented Mar 15, 2026

Description

Please see the 2nd commit. I don't think it's a correct change, but I noticed that extern struct/unions were still emitted into the C output as a typedef which causes double-typedefs for structs defined in a C header. I don't see any unit tests using extern struct/union to verify its behavior so I'm not sure if this is intended or a bug. It makes my use-case below work.

This registers extern struct and extern union as known extern symbols to quench the warning "assuming external C struct". I didn't change the branch for extern fn because they don't seem to have this issue.

#include "c_header_that_defines_dmon_structs.h"

extern struct dmon_watch_id;
extern struct dmon_action;

alias FsCallback = fn(dmon_watch_id, dmon_action, const char*, const char*, const char*, void*);

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant