airween
airween

Reputation: 6193

C compiler - list __builtin_ types

here is a small (and working) C code:

typedef __builtin_va_list __va_list;

int main() {
    return 0;
}

I found an answer, how gcc found the base type: Pycparser not working on preprocessed code

But how can I list all of the __builtin_ "base" types, which not defined explicitly?

Thanks, a.

Upvotes: 0

Views: 415

Answers (1)

John Bollinger
John Bollinger

Reputation: 181149

how can I list all of the __builtin_ "base" types, which not defined explicitly?

TL;DR: there is no general-purpose way to do it.

The standard does not define any such types, so they can only be implementation-specific. In particular, C does not attribute any significance to the __builtin_ name prefix (though such identifiers are reserved), nor does it acknowledge that any types exist that are not derived from those it does define. Thus, for most purposes, the types you are asking about should be considered an implementation detail.

If there were a way to list implementation-specific built-in types, it would necessarily be implementation-specific itself. For example, you might be able to find a list such as you are after in the compiler's documentation. You could surely derive one from the compiler's own source code, if that's available to you. You could maybe extract strings from the compiler binary, and filter for a characteristic name pattern, such as strings starting with "__builtin_".

You could also consider parsing all the standard library headers (with the assumption that they are correct) to find undeclared types, though that's not guaranteed to find all the available types. Moreover, with some systems, for example GNU's, the C standard library (to which the headers belong) is separate from the compiler.

Upvotes: 1

Related Questions