Skip to content

Conversation

@aedrax
Copy link

@aedrax aedrax commented Jan 12, 2022

This fixes the issue where a compiler puts multiple case statements on the same line and then has a conflict between the two.

For example, for whatever reason, somebody wanted to put

async_yield; async_yield;

They wouldn't be able to because it would expand into

*_async_k = 5; return ASYNC_CONT; case 5:; *_async_k = 5; return ASYNC_CONT; case 5:;

but this will (effectively) expand into:

*_async_k = 3; return ASYNC_CONT; case 3:; *_async_k = 5; return ASYNC_CONT; case 5:;

For what it's worth, __COUNTER__ is not in the C standard but is in most compilers

This fixes the issue where a compiler puts multiple case statements on
the same line and then has a conflict between the two
@naasking
Copy link
Owner

Hmm, I like the idea but don't like that it's not standard. I created async.h for use on my microcontroller projects that come with their own C compilers. Then again, not really a big deal to run the gcc/clang preprocessor and then the C compiler on the preprocessed source, so I'll have to think about this...

@shakna-israel
Copy link

What about a fallback using something like...

#ifndef __COUNTER__
    #define __COUNTER__ __LINE__
#endif

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

Successfully merging this pull request may close these issues.

3 participants