File: portability.txt

package info (click to toggle)
glade-nonus 0.6.4-5
  • links: PTS
  • area: main
  • in suites: woody
  • size: 12,152 kB
  • ctags: 3,879
  • sloc: ansic: 54,332; sh: 6,839; makefile: 743; sed: 93
file content (80 lines) | stat: -rw-r--r-- 1,884 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

This file notes some issues concerning how make Glade portable to different
operating systems. (Note that this also applies to source code generated by
Glade.)


Type Conversion
===============

If you need to convert gpointers to gints/guints and vice versa use the macros
GPOINTER_TO_INT, GINT_TO_POINTER, GPOINTER_TO_UINT, GUINT_TO_POINTER,
otherwise there are problems on Alphas. (These are defined in glib/glib.h)

e.g. instead of:
	index = (gint) selection->data;
use:
	index = GPOINTER_TO_INT (selection->data);


Strings
=======

If you need to include strings in the code which span multiple lines,
don't use embedded newlines.

e.g. instead of:
	fprintf(data->cfp,
"#include <gtk/gtk.h>
#include \"%s\"
#include \"%s\"\n\n",
	        data->signal_h_filename, data->main_h_filename);
use:
	fprintf(data->cfp,
		"#include <gtk/gtk.h>\n"
	        "#include \"%s\"\n"
	        "#include \"%s\"\n\n",
	        data->signal_h_filename, data->main_h_filename);

(The compiler concatenates them into one string.)

(gettext also prefers strings like this)


Don't use the result of sprintf() or its relatives (A problem occurred when
compiling on a Sparc LX + SunOS 4.1.3C + gcc 2.7.2.1).

e.g. instead of:
     pos += sprintf (pos, "%i", count);
use:
     sprintf (pos, "%i", count);
     pos += strlen (pos);


Library Functions
=================

I'm not too sure on this issue yet. Try to only use standard functions
such as strlen(), strcmp() etc. (see if GTK uses it.)

If you are unsure of the portability of a function make a note of it
somewhere (in a comment at the top of the file?).


Miscellaneous
=============

Don't use special features of gcc, such as dynamic initializers:
    GList glist = { current_child, NULL, NULL };

Use this instead:
    GList glist = { NULL, NULL, NULL };
    glist.data = current_child;


Don't use empty structs.



Damon, 8 July 1998.