Unnecessary warnings from GCC

General FreeBASIC programming questions.
Post Reply
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Unnecessary warnings from GCC

Post by pestery »

I did a quick search but didn't see any related topics so I thought I'd create this one, for warnings that seem unnecessary that are emitted from GCC when using the GCC back end.

Anyway, here's my probably unneeded warning, when using the Field command. My FB code is:

Code: Select all

Type datatype Field = 1
   As Integer v1
   As UByte   v2
   As Byte    v3
End Type
Dim As datatype dt
The warning was:

Code: Select all

D:\Programs\FreeBASIC\fbc -gen gcc "test2.bas"
test2.c:16: warning: 'packed' attribute ignored for field of type 'ubyte'
test2.c:17: warning: 'packed' attribute ignored for field of type 'byte'

Make done
And the generated C code is:

Code: Select all

// Compilation of test2.bas started at 16:55:17 on 04-18-2013
typedef char byte;
typedef unsigned char ubyte;
typedef unsigned short ushort;
typedef int integer;
typedef unsigned int uinteger;
typedef unsigned long ulong;
typedef long long longint;
typedef unsigned long long ulongint;
typedef float single;
typedef struct _string { char *data; int len; int size; } string;
typedef char fixstr;
typedef ushort wchar;
	typedef struct _DATATYPE {
		integer V1 __attribute__((packed));
		ubyte V2 __attribute__((packed));
		byte V3 __attribute__((packed));
	} DATATYPE;
void __attribute__((stdcall)) fb_Init( integer, char**, integer );
void __attribute__((stdcall)) fb_End( integer );
typedef struct _$fb_RTTI $fb_RTTI$type;
typedef struct _$fb_RTTI {
	void* STDLIBVT;
	char* ID;
	$fb_RTTI$type* PRTTIBASE;
} $fb_RTTI;
extern $fb_RTTI$type __fb_ZTS6Object;

integer main( integer __FB_ARGC__$, char** __FB_ARGV__$ )
{
	integer fb$result$;
	DATATYPE DT$;
	#define vr$0 ((integer*)(&fb$result$))
	__builtin_memset( vr$0, 0, (integer)4 );
	fb_Init( __FB_ARGC__$, __FB_ARGV__$, (integer)0 );
	label$0:;
	#define vr$1 ((DATATYPE*)(&DT$))
	__builtin_memset( vr$1, 0, (integer)6 );
	label$1:;
	fb_End( (integer)0 );
	#define vr$2 ((integer)(fb$result$))
	return vr$2;
}
// Total compilation time: 0.0001004800000772299 seconds. 
Maybe someone knows why this warning appears, but if you check the size of the datatype then everything seems to be ok. I don't really know. It's just a warning that doesn't seem needed and I thought I'd mention it.

Oh, and I'm using Window 7 64bit, the "FreeBASIC Compiler - Version 0.24.0 (08-19-2012) for win32" and the GCC compiler is the one that comes bundled with CodeBlocks, no idea what version.
Last edited by pestery on Apr 19, 2013 1:33, edited 1 time in total.
marcov
Posts: 3503
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Unnecessary from GCC

Post by marcov »

The codegenerator probably adds some byte packing directive to byte, which by definition is bytepacked anyway.
dkl
Site Admin
Posts: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Unnecessary from GCC

Post by dkl »

This should be fixed in the next FB release, see also this commit.
Gonzo
Posts: 722
Joined: Dec 11, 2005 22:46

Re: Unnecessary from GCC

Post by Gonzo »

dkl, you don't have to use ((packed)) either, if its a field = N
you can also just use
#pragma pack(push, N) ie. pack(push, 1)
typedef struct
...
} some_t;
#pragma pack(pop)

at least it will look cleaner, no warnings, and no $%#@
i've had issues with ((packed))
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Re: Unnecessary warnings from GCC

Post by pestery »

Cool, another warning removed from GCC. Also I updated the topic title because I mucked it up the first time :P
Post Reply