Next Previous Contents

4. Usage restriction

The strategy used is mainly targeted at C++ code. With some restriction, it may be used for C code. Here are the main feature that probably don't work with C.

static initialization

In C++ one can write the following code.

                static char *tb[]={

where foo is a function. The C++ compiler will generate the proper code which will be probably called once. The MSG_U macro (and others) are not hiding function call, but are indeed dynamic in some sens. C does not support this. Other translation strategy based on dictionary do have the same limitation though.

The example using the static char *tb[] is also causing a problem in C++ if the variable is declared outside of a function. The problem appear because the "hidden" initialization code generated by the compiler is called very early, often before main() is called. Normally, the function translat_load() which bring the dictionary in memory is called by main().

Fortunately, the current implementation, where _dictionary_system is a pointer will trigger a seg fault whenever this condition is met. This fault will be trigger all the time, because all initialization are called before main. The strategy is safe.

Next Previous Contents