英文:
Don't allow nested switches in GCC
问题
我在C语言中使用协程,使用多个宏来简化代码编写。众所周知,这些宏将代码封装在一个大的switch
语句中,并使用case __LINE__
来确定返回位置。问题在于,在协程内部使用switch
会导致失败,因为case __LINE__
将属于内部switch
而不是外部的。
通过向GCC传递参数,是否可以“禁用”嵌套switch
支持,以确保将一个switch
放在另一个switch
内会导致错误或至少警告?
英文:
I'm using coroutines in C using several macros to simplify writing code. As it is known, these macros encapsulate the code inside a big switch
statement, and use case __LINE__
to know where to return. The problem is that using a switch inside a coroutine will make it fail, because the case __LINE__
will belong to the inner switch
, and not the outer one.
Is it possible, by passing a parameter to GCC, to "disable" nested switch support, thus ensuring that putting a switch inside another switch will return an error or, at least, a warning?
答案1
得分: 1
不,gcc
不支持这个。
英文:
> Is it possible, by passing a parameter to GCC, to "disable" nested switch support, thus ensuring that putting a switch inside another switch will return an error or, at least, a warning?
No, gcc
does not have support for this.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论