[Tinyos-devel] Annotate constants inside an enum with attribute in nesc

Rodrigo Fonseca rfonseca at cs.berkeley.edu
Fri Apr 10 09:31:59 PDT 2009


Hi,

I am trying to add nesc annotations to specific constants within my
program to be able to filter them out easily later, however nothing
that I've tried so far has worked.
Here's what I am trying to do:

------------------
struct @quanto_constant{};
#define QUANTO_RESOURCE_IDS "quanto_resource_ids"
#define NEW_QUANTO_RESOURCE_ID ((uint8_t) unique(QUANTO_RESOURCE_IDS))

enum {
    CPU_RESOURCE_ID = NEW_QUANTO_RESOURCE_ID,
};
-----------------

If I compile with '-fnesc-dump=constants' I get all constants in the program.
None of

enum {
    @quanto_constant() CPU_RESOURCE_ID = NEW_QUANTO_RESOURCE_ID,
    CPU_RESOURCE_ID @quanto_constant() = NEW_QUANTO_RESOURCE_ID,
    CPU_RESOURCE_ID = @quanto_constant() NEW_QUANTO_RESOURCE_ID,
    CPU_RESOURCE_ID = NEW_QUANTO_RESOURCE_ID @quanto_constant(),
};

compile.

This:
enum {
    CPU_RESOURCE_ID = NEW_QUANTO_RESOURCE_ID,
} @quanto_constant();

compiles, and gives me only this enum back, which is a start.

But if I do '-fnesc-dump=tags(attribute(quanto_constant))'
'-fnesc-dump=referenced(constants)' , it doesn't pull in the constants
referenced by the filtered enum.

I can do a trick with the names of the constants I want to extract,
but having the tag work for individual constants would be nice.
I could also use ncg, but I don't know in advance all the constants I
will extract, and they will vary from application to application.

Any ideas? Am I missing something? Is this not possible?

Thanks,
Rodrigo



More information about the Tinyos-devel mailing list