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

Using of return operator. #3

Open
0xfk0 opened this issue Mar 18, 2022 · 2 comments
Open

Using of return operator. #3

0xfk0 opened this issue Mar 18, 2022 · 2 comments

Comments

@0xfk0
Copy link

0xfk0 commented Mar 18, 2022

Hello...

I have a proposition.

You can redefine return operator to an expression like:

#define return (0 ? &some_var : (some_type*)0),

Then you globally define some_var with some_type and locallly (in each function, via macros providing RAII) you re-declaring some_var with some_type2. Where some_type and some_type2 must be defined just like typedef struct { int dummy[1]; } some_type.

As a result, you will get compile error if you will try to perform return from block of code where RAII is assumed.

@0xfk0
Copy link
Author

0xfk0 commented Mar 18, 2022

See similar approach proposed for scoped locks: https://groups.google.com/g/comp.lang.c/c/KPeoMxlTqjI/m/ISz5IBifBgAJ

@Qqwy
Copy link
Owner

Qqwy commented Mar 18, 2022 via email

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