J'ai fait le code suivant :
// C Source File
// Created 01/07/2008; 14:00:03
// Delete or comment out the items you do not need.
#include <tigcclib.h>
#include "font.h"
#define err(s) {ST_helpMsg(s); return;}
short chk_font(void)
{
SYM_ENTRY *sym = SymFindPtr($("main\gfont"),0);
if (!sym) return FALSE;
return TRUE;
}
short create_font(void)
{
//2 octets pour la taille du fichier
//1 octet pour la taille en lignes d'un caractère : 7
//LISTE DES CARACTERES : " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" => 37 caractères * sizeof(unsigned char)
//'\0' de fin de données
//Extension : GFNT : 4 octets
//'\0' de fin d'extension personnelle
//OTH_TAG : 1 octet
//'\0' de fin
//total : 2 + 1 + 37 * sizeof(unsigned char) * 7 + 1 + 4 + 1 + 1 + 1 = 270
HANDLE h = HeapAlloc(270);
SYM_ENTRY *sym = DerefSym(SymAdd($("main\gfont")));
sym -> handle = h;
char *begin = HeapDeref(h);
short size = 270;
*(unsigned short*)begin = size - 2; //270 - 2
memcpy(begin + 2, car_list, sizeof(car_list)/sizeof(unsigned char));
begin[size - 7] = '\0';
strcpy(begin + size - 6, "GFNT");
begin[size - 1] = OTH_TAG;
return 0;
}
// Main Function
void _main(void)
{
short font_exists;
short error;
font_exists = chk_font();
if (!font_exists) error = create_font();
if (error) err();
}
Mais lors de la compilation, TIGCC me sort une erreur : "expected expression before 'short' et m'envoie sur la ligne
"short chk_font(void)"
qu'est-ce que TIGCC attend comme expression alors ? pour déclarer une fonction c'est bien
type du retour nom de la fonction (type1 argument 1, type 2 argument 2 ...)
?
EDIT : urgh, trompé dans les balises
(au fait j'ai oublié un r dans la toute dernière ligne, parce qu'il y a déjà une fonction err() qui existe