C11 _Generic: how to deal with string literals?

前端 未结 3 1581
悲&欢浪女
悲&欢浪女 2020-12-03 10:21

Using the _Generic feature in C11, how do you deal with string literals?

For instance:

#include 
#define foo(x) _Generic(         


        
3条回答
  •  遥遥无期
    2020-12-03 10:41

    The behaviour of Clang was incorrect (C11 Defect report 481) until 3.7.1. It was fixed in Clang 3.8.0, released on March 8, 2016.

    The Committee response to the DR 481 says the following:

    This paper elicited a long and productive discussion. The committee agrees with the author of the _Generic proposal that the intent was that selecting on qualified types was explicitly to be avoided as was selecting on arrays by size. The intent of _Generic was to give C a mechanism to somewhat express the notion of “overloaded function” found in C++, and in particular a possible mechanism for implementors to use to implement the atomic type generic functions from section 7.17.7.

提交回复
热议问题