honestly i don’t known how to post this question…
I have a global dynamic list that is visible by all function of the program,
since today this list were filled reading data from a file.
but now i want to have a internal “list” that is loaded if no file it’s specified.
the list element are this:
// odb tuple
typedef struct _odb_t
{
const char *name,*value;
struct _odb_t *next;
} odb_t;
enum _method {GET,POST};
// odb type binding
typedef struct _odb_type
{
enum _type type;
const char *value;
struct _odb_type *next;
} odb_type;
// defining online_db struct
typedef struct _odb
{
const char *host,*file,*patrn;
enum _method method;
odb_type *types;
odb_t *tuples;
pthread_t thread; // the thread that is using this host
struct _odb *next;
} odb;
how can i have an internal list into the .text section?
thanks in advance.
With C99 you can have so-called compound literals as some kind of unnamed variables and designated initializers to ease the writing of initializers. Your structures are a bit complicate that I can capture their complete meaning on a first glance, but something analogous to that here should work.
Sure that you would have to initialize the other pointer fields analogously with the correct data, but I hope you get the idea.
When used in file scope compound literals of the form
(typename){ initiliazers }are allocated statically.