Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@cInclude("winsock2.h") fails to handle multicharacter literal #4194

Closed
mikdusan opened this issue Jan 15, 2020 · 5 comments · Fixed by #4939
Closed

@cInclude("winsock2.h") fails to handle multicharacter literal #4194

mikdusan opened this issue Jan 15, 2020 · 5 comments · Fixed by #4939
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. os-windows translate-c C to Zig source translation feature (@cImport)
Milestone

Comments

@mikdusan
Copy link
Member

reduction: ws.zig

const c = @cImport({
    @cInclude("winsock2.h");
});

export fn foo() void {
    var ws: c.WSADATA = undefined;
}

command: zig build-exe ws.zig -lc

zig-cache\o\X_taigvKlaSL0Ni7WvXJhwwQNAb7JSTXans6wCe2RuMSTfhndUY2K91GxGNfXhJ9\cimport.zig:47018:24: error: invalid character: 'R'
pub const LCS_sRGB = 'sRGB';
                       ^
@mikdusan mikdusan added bug Observed behavior contradicts documented or intended behavior os-windows labels Jan 15, 2020
@mikdusan mikdusan changed the title cInclude("winsock2.h") fails to handle multicharacter literal @cInclude("winsock2.h") fails to handle multicharacter literal Jan 15, 2020
@mikdusan mikdusan added the translate-c C to Zig source translation feature (@cImport) label Jan 16, 2020
@Diltsman
Copy link

Prior versions of Zig didn't generate any code in cimport.zig for LCS_sRGB.

@Rocknest
Copy link
Contributor

Cannot reproduce. Probably translated from:

typedef enum {
    LCS_CALIBRATED_RGB = 0x00000000,
    LCS_sRGB = 0x73524742, // s R G B
    LCS_WINDOWS_COLOR_SPACE = 0x57696E20
} LogicalColorSpace;

@andrewrk andrewrk added this to the 0.7.0 milestone Jan 17, 2020
@andrewrk
Copy link
Member

Add -target x86_64-windows-gnu to @mikdusan's command line above and you'll be able to reproduce it on any OS.

@andrewrk andrewrk added the contributor friendly This issue is limited in scope and/or knowledge of Zig internals. label Jan 17, 2020
@Diltsman
Copy link

This documents the Microsoft specific implementation of multicharacter char literals.

https://docs.microsoft.com/en-us/cpp/cpp/string-and-character-literals-cpp?view=vs-2019

@Diltsman
Copy link

How should multicharacter literals be treated? It is implementation dependent in C.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. os-windows translate-c C to Zig source translation feature (@cImport)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants