opened
tiehuis
username_0
For example in the generated [here](https://username_0.github.io/iterative-replacement-of-c-with-zig) `#ifndef COMPUTE.ZIG_COMPUTE.ZIG_H` is invalid and everything after the `.` is not considered part of the token.

Since presumably these can contain any input characters, some sort of suitable normalization needs to be performed so the guards are valid identifiers.
Make generated C header file guards conform to standard naming
issue
created
raulgrell
username_1
Could we simply use a double underscore `__` instead of the `.`?
comment
created
andrewrk
username_2
Yes. It's not a hard problem to solve, it's just that area of code hasn't been fully developed yet. It actually could be a good area for a new contributor to ease into the codebase
comment
created
raulgrell
username_1
I'll give it a shot. I'm working on a little game engine that i'd like to be able to mix and match c and zig code, so that for example, you can write the platform layer in C, which calls zig engine code that uses a c library for netcode.
comment
created
andrewrk
username_2
That's a great use case. You're probably going to run into some issues. When you do, please report them and we'll get them all sorted out. I prioritize fixing issues that are blocking zig users from working on their projects.
comment
created
raulgrell
username_1
I've run into plenty of issues already =P mostly stuff that's easy to work around like TODO asserts and other asserts that  don't give an indication of where the issue is. I've wanted to report them but i havent been able to reproduce them with a simple case. I hope to be able to put my code up in the next couple of weeks, i just haven't had enough time lately. Ive also got a few things that might be useful for the stdlib. Theyll be in my 'tick' and 'zig-misc' repos respectively
comment
created
raulgrell
username_1
Also, i havent started the audio layer yet, is your libsoundio library usable from zig?
comment
created
andrewrk
username_2
There are tricks to figure out what code causes the asserts if you run in a debugger. You can find out the source AST node and from that print the file, line, and column. 

Libsoundio is indeed directly usable from zig - it was one of the examples that I made sure all the symbols from the .h file were recognized.

I'll have a look at your zig repos. Exciting stuff!
comment
created
tiehuis
username_0
Just a reminder that you'll probably want to handle arbitrary input and not just dots.

For example `Ω%4.zig` will result in the header guard `Ω%4Ω%4_Ω%4_H`.

Valid identifiers are the usual `[A-Za-z_][A-Za-z0-9_]*` form. I'd say this nearly calls a specific name-mangling strategy as well since foreign characters in files could easily map to the same identifier if a simple replacement strategy is used.

e.g. `%%##$,zig` and `^#&^%.zig` would map to the same value if just performing a replacement with underscores.

Just something to think about, starting off simple will already be an improvement!
comment
created
andrewrk
username_2
Agreed. I would propose something similar to the way percent escaping works in URLs.  E.g. choose `_` as the special character, and then anything that is not `[a-zA-Z][a-zA-Z0-9]*` gets `_xx` where xx is the hex code for the byte outside the alphabet.
comment
created
raulgrell
username_1
That's a pretty good solution. Should we surround the special characters with underscores instead of just a prefix? That way the name mangling could support unicode and actually be fully reversible in the case a special character is followed by something hex-like.

- `Ω%4.zig` would become `_03A9__25_4_2E_ZIG_H`
- `compute_helper.zig` would become `COMPUTE_5F_HELPER_2E_ZIG_H`

where `2E = .` and `5F == _`.

If we want to keep the mangled names prettier in the usual case of `[a-zA-Z][a-zA-Z0-9]*` filenames, the dot can be a special case and convert to a double underscore.
comment
closed
andrewrk
username_2
issue