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

fstr_t stack allocations is horrible and cannot be done in a single statment (FSTR_STACK_DECL) #12

Closed
hnsl opened this issue Oct 10, 2014 · 4 comments
Labels

Comments

@hnsl
Copy link
Owner

hnsl commented Oct 10, 2014

The FSTR_STACK_DECL macro is too long and makes my eyes bleed. It also a multiple assignment pattern (cancer™).

Suggested solution:

#define fstr_stack_alloc(n) ({ uint8_t _mem[n]; FSTR_PACK(_mem); })

Is the stack of the extended GCC context valid after it returns?

@simonlindholm
Copy link
Contributor

Don't know, but I doubt it. Can't we just make FSTR_STACK_DECL declare the variable name you pass in?

@hnsl
Copy link
Owner Author

hnsl commented Oct 10, 2014

That's an option. But don't you think it's worth investigating?

Proposal:

#define fstr_stack(name, length) name; uint8_t _##name##_buf[length]; name = (fstr_t) {.len = length, .str = _##name##_buf};

fstr_t fstr_stack(foo, 2);

@simonlindholm
Copy link
Contributor

I'm not convinced it's worth coming up with such complicated macros for a relatively uncommon feature, and FSTR_STACK_DECL has the advantage that it's obvious at a glance what it's doing.

@hnsl
Copy link
Owner Author

hnsl commented Oct 15, 2014

Okay, marking this as wontfix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants