我已经了解了一些在libgcc中定义的类型。它们显然都映射到同一个名为bogus_type的类型。我找不到它的定义。
#define SItype bogus_type
#define USItype bogus_type
#define DItype bogus_type
#define UDItype bogus_type
#define SFtype bogus_type
#define DFtype bogus_type此类型映射到什么?它甚至是一个有效的类型还是像NULL这样的类型
发布于 2015-06-17 22:59:20
正在使用的此“类型”的Here's another example。
/* Make sure that we don't accidentally use any normal C language built-in
type names in the first part of this file. Instead we want to use *only*
the type names defined above. The following macro definitions insure
that if we *do* accidentally use some normal C language built-in type name,
we will get a syntax error. */
#define char bogus_type
#define short bogus_type
#define int bogus_type
#define long bogus_type
#define unsigned bogus_type
#define float bogus_type
#define double bogus_type也就是说,不是一个类型。这是一个合法的代码破解者,它强制限制在程序的特定位置使用特定类型的。如果它被触发,编译将失败并出现语法错误,因为bogus_type不存在。
它并不是语言中任何“鲜为人知”的部分,它只是巧妙地使用了C预处理器。
发布于 2015-06-17 23:00:59
它被放在一些不应该在以后意外使用这些类型的代码之前。因此,如果它正在使用其中一个类型,编译器将抛出一个错误,因为没有这样的bogus_type类型。
发布于 2015-06-17 23:06:23
因为define只是在编译阶段之前发生的文本替换,所以只要没有人使用定义的类型,bogus_type就不会被替换,也不会发生任何事情。如果有人要使用这些类型,它们将被替换为bogus_type,这实际上没有在任何地方定义,这将使编译失败。
因此,基本上bogus_type只是一个拉比,用于在特定类型使用的情况下强制使构建失败。出于这个原因,它可能是:
#define SItype you_are_using_a_type_you_should_not_be_using!https://stackoverflow.com/questions/30895120
复制相似问题