TextAttr Solved

This forum is for general developer support questions.
Post Reply
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 5:47 pm
Contact:

TextAttr Solved

Post by JosDuchIt »

Solved:

it wa a problem of where the "include" was included


In the following line i corrected what seemd errors to me
///struct TextAttr Topaz80 = {"topaz.font", 8, 0, 0, }; ///<graphics/text.h> /// variable 'Topaz80' has initializer but incomplete type
into
struct TextAttr Topaz80 = {"topaz.font", 8, '0', '0' }
and later into
struct TextAttr Topaz80 = {
.ta_Name = "topaz.font",
.ta_YSize = 8 ,
.ta_Style = '0' ,
.ta_Flags = '0'
};

for the last i get the errors

guis:Dev/GCView/Def_struct.h:13: error: variable 'Topaz80' has initializer but incomplete type
guis:Dev/GCView/Def_struct.h:14: error: unknown field 'ta_Name' specified in initializer
guis:Dev/GCView/Def_struct.h:14: warning: excess elements in struct initializer
guis:Dev/GCView/Def_struct.h:14: warning: (near initialization for 'Topaz80')
guis:Dev/GCView/Def_struct.h:15: error: unknown field 'ta_YSize' specified in initializer
guis:Dev/GCView/Def_struct.h:15: warning: excess elements in struct initializer
guis:Dev/GCView/Def_struct.h:15: warning: (near initialization for 'Topaz80')
guis:Dev/GCView/Def_struct.h:16: error: unknown field 'ta_Style' specified in initializer
guis:Dev/GCView/Def_struct.h:16: warning: excess elements in struct initializer
guis:Dev/GCView/Def_struct.h:16: warning: (near initialization for 'Topaz80')

I am pretty sure the <graphics/text.h> file is included which states

/****** TextAttr node, matches text attributes in RastPort **********/
struct TextAttr
{
STRPTR ta_Name; /* name of the font */
UWORD ta_YSize; /* height of the font */
UBYTE ta_Style; /* intrinsic font style */
UBYTE ta_Flags; /* font preferences and flags */
};


What can explain the results above ??
Hiow can i test if an 'include' is indeed included?.
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 530
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: TextAttr Solved

Post by salass00 »

Code: Select all

struct TextAttr Topaz80 = {
    "topaz.font",
    8,
    FS_NORMAL,
    0
};
You're two "fixed" versions set ta_Style and ta_Flags to the character constant '0' (i.e. ASCII code for '0' which is 48) instead of the value 0. This is completely wrong as ta_Style is supposed to be either set to 0 (FS_NORMAL) or a bitwise or combination of style flags together (FSF_xxx constants in graphics/text.h) while ta_Flags should be set to 0 or a bitwise or combination of font flags (FPF_xxx constants in graphics/text.h). F.e. for bold and italic text you would use FSF_BOLD|FSF_ITALIC instead of FS_NORMAL.

Make sure that the graphics/text.h file is included before the part where the Topaz80 variable is defined in your code. Ideally all your include commands should be at the top of your source code file before any code (you can have a comment with copyright and such before it though).

In order to check what happens when files are included you can run just the C preprocessor by using the -E command line option:
gcc -E test.c -o preprocessed_test.c
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 5:47 pm
Contact:

Re: TextAttr Solved

Post by JosDuchIt »

@salass00

Thanks for the explanations.
Post Reply