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

#sizeof doesn't work on struct fields #171

Open
jchia opened this issue Aug 19, 2016 · 0 comments
Open

#sizeof doesn't work on struct fields #171

jchia opened this issue Aug 19, 2016 · 0 comments

Comments

@jchia
Copy link
Contributor

jchia commented Aug 19, 2016

Trying to c2hs the following Foo.chs fails with "The phrase '.' is not allowed here." I want to get back 10. Replacing #sizeof with #offsetof causes c2hs to succeed. I think #sizeof should evaluate similarly to sizeof in C++ (sizeof(Foo::bar)). (I don't know how it can be done straightforwardly in C.)

/* Foo.h */
struct Foo {
    char bar[10];
};
-- Foo.chs

#include "Foo.h"

module Foo where

sizeOfFooBar :: Int
sizeOfFooBar = {#sizeof Foo.bar#}
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

No branches or pull requests

1 participant