You are not logged in.

#1 2011-04-07 10:33:11

Cagnulein
Member
From: Modena, Italy
Registered: 2006-04-03
Posts: 260
Website

[C] Compiling a list of variables

Hi guys, i'm writing a software in C and i have to create a sort of 'macro' that compiles a list of global variables decleared.

Example:

MACROLIST unsigned short a;
MACROLIST unsigned long b;
MACROLIST char c[12];

What i have in mind is using a macro before every variable declaration, in order to insert every variable in a virtual list.
My target is:

int i;
for(i=0;i<num_variables;i++)
{
   printf("%ld",&var[i]);
}

How could i get this?

Offline

#2 2011-04-07 14:08:46

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: [C] Compiling a list of variables

I don't think that's possible.

You may be able to do that in C99 for local variables (in a function), though...

May I ask what your goal is?

Offline

#3 2011-04-07 15:33:32

Cagnulein
Member
From: Modena, Italy
Registered: 2006-04-03
Posts: 260
Website

Re: [C] Compiling a list of variables

I've got a source code for an embeeded application (PowerPC) without operating system.
Now i'm porting in it on Qt on linux on a ARM and i want to save the contents of all the variables in a file.

Offline

Board footer

Powered by FluxBB