不允许在GCC中嵌套开关。

huangapple go评论87阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年2月14日 05:49:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/75441528.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定