This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Creating a variable declaration of custom type.
- From: "Ferad Zyulkyarov" <feradz at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 15 Jan 2007 13:05:51 +0100
- Subject: Creating a variable declaration of custom type.
Hi,
When the code is being parsed in c-parser.c I try to transparently
create a variable declaration of custom type within the code being
compiled. The name of the custom type is "MyType" (defined in some
header file by typedef).
In my source file I have a function:
void foo()
{
...;
}
At the time of parsing I want to make declaration as if the function
above is written like that:
void foo()
{
MyType *t;
...;
}
The code that I use to do it is as follows:
tree type_id, type_node, var_decl;
type_id = get_identifier("MyType");
type_node = make_node(POINTER_TYPE);
TYPE_NAME(type_node) = type_id;
var_decl = build(VAR_DECL, get_identifier("t"), type_node);
But, when I compile my source with the modified GCC (as above) I get
an error: "t" has an incomplete type. I know that I miss something but
I cannot figure out what is it.
Your help will be appreciated very much. Thanks a lot.
--
Ferad Zyulkyarov
Barcelona Supercomputing Center