← Back to team overview

kicad-developers team mailing list archive

Re: Call for help to compile a small test program with g++ version 4.7.3 and more.

 

On Jun 17, 2013 6:21 AM, "Brian Sidebotham" <brian.sidebotham@xxxxxxxxx>
wrote:
>
> On 17 June 2013 11:59, Dick Hollenbeck <dick@xxxxxxxxxxx> wrote:
>>
>>
>> On Jun 17, 2013 5:02 AM, "Milan Horák" <stranger@xxxxxxxxxx> wrote:
>> >
>> > Hello,
>> >
>> > I am getting:
>> >
>> > g++ -Wall -O2 -I /g/boost_1_53_0 test_polygon_diff.cpp
>> >
>> > test_polygon_diff.cpp: In function ‘void dumpPolySet(const
KI_POLYGON_SET&)’:
>> > test_polygon_diff.cpp:84:60: warning: format ‘%d’ expects argument of
type ‘int’, but argument 2 has type
‘std::vector<boost::polygon::polygon_data<int> >::size_type {aka long
unsigned int}’ [-Wformat]
>> > test_polygon_diff.cpp:88:71: warning: format ‘%d’ expects argument of
type ‘int’, but argument 3 has type ‘std::size_t {aka long unsigned int}’
[-Wformat]
>> >
>> > Am I doing something wrong?
>>
>> No.
>>
>> size_t is 64 bits on a 64 bit platform while int on that same platform
is 32 bits even though it's a 64 bit program.
>>
>> This is why I don't use size_t by choice.  But for function return
values like this %zd works well.
>>
>> The z modifier is designed for use with size_t.
>>
>>
> Ah nice, I didn't know about the %z formatter.

Modifier, so its %zd not %z.

Or you can cast the argument down to 32 bits since 2 or 4 billion is
usually enough of stuff.

Follow ups

References