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

error compiling butch[1] #5

Closed
rofl0r opened this issue Nov 27, 2012 · 2 comments
Closed

error compiling butch[1] #5

rofl0r opened this issue Nov 27, 2012 · 2 comments

Comments

@rofl0r
Copy link

rofl0r commented Nov 27, 2012

butch.c:512:18: error: Initialisation expression '&(stringptr){ ("#!/bin/sh\n%BUTCH_CONFIG\nexport butch_package_name=%BUTCH_PACKAGE_NAME\nbutch_cache_dir="$C"\nwget -O "$butch_cache_dir/%BUTCH_TARBALL" '%BUTCH_MIRROR_URL'\n"), (sizeof("#!/bin/sh\n%BUTCH_CONFIG\nexport butch_package_name=%BUTCH_PACKAGE_NAME\nbutch_cache_dir="$C"\nwget -O "$butch_cache_dir/%BUTCH_TARBALL" '%BUTCH_MIRROR_URL'\n") - 1) }' is not constant

[1] https://github.com/rofl0r/butch
tarball with embedded dependencies and portable Makefile is available here https://github.com/downloads/rofl0r/butch/butch-0.1.5.tar.bz2 (62KB)

btw, this test program here works

typedef struct str_struct {
        char *s;
        unsigned long l;
} str;

#define STRLIT(A) &(str) { (A), sizeof((A) - 1) }

str *test(void) {
        return STRLIT("test");
}
@rofl0r
Copy link
Author

rofl0r commented Nov 27, 2012

here is a testcase that can reproduce the bug

typedef struct str_struct {
        char *s;
        unsigned long l;
} str;

#define STRLIT(A) &(str) { (A), sizeof((A) - 1) }

enum foo {
        FOO = 0,
        BAR,
        BAZ
};

const str *arr[BAZ] = {
        [FOO] = STRLIT("foo"),
        [BAR] = STRLIT("bar"),
};

@MatzeB
Copy link
Member

MatzeB commented Nov 28, 2012

Your testcase is fixed in d7384b0.
(Also note that your first "working" testcase will fail in practice since compound literal in functions have automatic storage and can get deallocated when the function exits.)

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

2 participants