2 * This file is part of cparser.
3 * Copyright (C) 2012 Matthias Braun <matze@braunis.de>
8 #include "attribute_t.h"
9 #include "write_compoundsizes.h"
11 void write_compoundsizes(FILE *output, const translation_unit_t *unit)
13 for (const entity_t *entity = unit->scope.entities;
14 entity != NULL; entity = entity->base.next) {
15 if (entity->kind != ENTITY_TYPEDEF)
18 type_t *type = skip_typeref(entity->typedefe.type);
19 if (!is_type_compound(type))
22 /* see if we have the required attributes */
23 const compound_t *compound = type->compound.compound;
24 bool had_dllexport = false;
25 const char *string = NULL;
26 for (const attribute_t *attrib = compound->attributes;
27 attrib != NULL; attrib = attrib->next) {
28 if (attrib->kind == ATTRIBUTE_GNU_DLLEXPORT)
30 if (attrib->kind == ATTRIBUTE_GNU_DEPRECATED) {
31 const attribute_argument_t *argument = attrib->a.arguments;
32 assert(argument != NULL && argument->kind == ATTRIBUTE_ARGUMENT_EXPRESSION);
33 const expression_t *expr = argument->v.expression;
34 assert(expr->kind == EXPR_STRING_LITERAL);
35 string = expr->string_literal.value.begin;
39 if (had_dllexport && string != NULL) {
40 fprintf(output, "%s %u\n", string, get_type_size(type));