[Fribidi-discuss] (Justified?) compilation warning (fwd)
Shachar Shemesh
fribid-discuss at sun.consumer.org.il
Sat Sep 28 07:29:01 EST 2002
Shachar Shemesh wrote:
>
> The actual attached code will come in a little while, in a seperate mail.
>
> Shachar
Ok, here's the explanation of what's going on here.
fribidi_utf.h - project's header file.
This is where both the specific encodings functions and types are
declared, and a default is selected. The default is selected based on
the value of a macro called "FRIBIDI_CHAR_BYTES". If that is not
defined, it is set to 4 (and thus, backwards compatibility is fully
maintained).
fribidi_utf.c - The library's source
In here, the function fribidi_log2vis is defined for one encoding only.
You will notice the lack of #ifdef in this file (actually, I cheated a
little to print the string's width, by placing a #define that didn't
really belong there in the header files. This would not happen in a
library that actually does something, however, and the only #ifdef we
are expected to see in the real implementation is when actual alogrithm
differ between the different widths, probably due to optimizations).
main.c - A source to an extrenal program that uses fribid.
This program nicely shows how both the default encoding can be used (and
selected based on the default required), as well as non-default
encodings used when applicable.
Makefile - don't you know what that is?
There are two special tricks performed in this makefile.
The first is for compiling fribidi_utf.c three times, selecting a
different default each time. The three .o files are then merged into a
single library.
The second should not be in fribidi's Makefile, and will probably not be
necessary for the using program's Makefile either. It is therefor ok
that it is a little patchy. It allows compiling the test program in
three flavours. Please notice, however, that all three flavours are
linked against the same library.
In order to build the three test programs, run "make main8", "make
main16" and "make main32". You will get three programs with apropriate
names.
Notice that no conversions were used throughout the sources, static
typing is kept whether you use the default or override it. A program
that needs the default most of the time but occasionally needs a
different encoding will still get a warning if the wrong function is
called by mistake. The entire thing compiles without a single warning.
Shachar
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: application/x-java-vm
Size: 285 bytes
Desc: not available
Url : http://freedesktop.org/pipermail/fribidi/attachments/20020928/32ff68b7/Makefile.class
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fribidi_utf.c
Type: text/x-csrc
Size: 176 bytes
Desc: not available
Url : http://freedesktop.org/pipermail/fribidi/attachments/20020928/32ff68b7/fribidi_utf.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fribidi_utf.h
Type: text/x-chdr
Size: 811 bytes
Desc: not available
Url : http://freedesktop.org/pipermail/fribidi/attachments/20020928/32ff68b7/fribidi_utf.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.c
Type: text/x-csrc
Size: 381 bytes
Desc: not available
Url : http://freedesktop.org/pipermail/fribidi/attachments/20020928/32ff68b7/main.c
More information about the FriBidi
mailing list