[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] Initializing static/global variables
From: |
Robert Ammerman |
Subject: |
[lwip-devel] Initializing static/global variables |
Date: |
Tue, 26 Jun 2007 12:25:20 -0400 |
Not to beat a dead horse, but...
A simpler solution. In the ".h" files, NEVER initialize any static globals,
instead declare them like:
extern int xxx_abc;
extern int xxx_def[3];
extern int xxx_ghi[20];
Then in the appropriate ".c" file:
#if !defined(LWIP_DYNAMIC_INITIALIZATION)
int xxx_abc = 0;
int xxx_def = {1,2,3};
int xxx_ghi = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
#endif
void xxx_init()
{
#if defined(LWIP_DYNAMIC_INITIALIZATION)
xxx_abc = 0;
xxx_def[0] = 1; xxx_def[1] = 2; xxx_def[2] = 3;
{ int _i; for (_i=0; _i<20; ++_i) xxx_ghi[_i] = _i; }
#endif
}