← Back to team overview

widelands-dev team mailing list archive

Re: strcmp

 

Not sure what the problem is - without full compiler output. 

But you should not use strcmp() anyways. Nor should you use const char*. Instead use std::string and operator==() to compare them. 

> Am 18.07.2014 um 11:16 schrieb Tibor Bamhor <tiborb95@xxxxxxxxx>:
> 
> I think the problem is with bo.mines_
> 
> integer can be evaluated as bool without problems, even in the widelands code there is a lot of examples where output of strcmp is not compared to 0.
> 
> 
> 2014-07-18 11:03 GMT+02:00 Fòram na Gàidhlig <fios@xxxxxxxxxxxxxxxxxxx>:
>> The output of strcmp is an int and not a boolean - maybe that's your
>> problem?
>> 
>> http://www.cplusplus.com/reference/cstring/strcmp/
>> 
>> 
>> 18/07/2014 08:09, sgrìobh Tibor Bamhor:
>> > Hi,
>> >
>> > please help me with trivial programming question. I am doing this:
>> >
>> > if (strcmp(bo.mines_, "marble"))
>> >
>> > and getting this:
>> >
>> > error: invalid conversion from 'int32_t {aka int}' to 'const char*'
>> > [-fpermissive]
>> >
>> > member mines_ is defined as
>> >
>> > char* mines_;
>> >
>> > in ai_hints.h
>> >
>> > What should be the right syntax?
>> >
>> > Thanks!
>> >
>> >
>> >
>> > _______________________________________________
>> > Mailing list: https://launchpad.net/~widelands-dev
>> > Post to     : widelands-dev@xxxxxxxxxxxxxxxxxxx
>> > Unsubscribe : https://launchpad.net/~widelands-dev
>> > More help   : https://help.launchpad.net/ListHelp
>> >
>> >
>> >
>> > No virus found in this message.
>> > Checked by AVG - www.avg.com <http://www.avg.com>
>> > Version: 2014.0.4716 / Virus Database: 3986/7871 - Release Date: 07/17/14
>> >
>> 
>> _______________________________________________
>> Mailing list: https://launchpad.net/~widelands-dev
>> Post to     : widelands-dev@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~widelands-dev
>> More help   : https://help.launchpad.net/ListHelp
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~widelands-dev
> Post to     : widelands-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~widelands-dev
> More help   : https://help.launchpad.net/ListHelp

References