wxConfigBase reading int value

10 views
Skip to first unread message

Igor Korot

unread,
Jan 16, 2023, 3:31:21 AM1/16/23
to wx-u...@googlegroups.com
Hi, ALL,
I'm using the latest release on all 3 major platforms.

Compiling my code on Mac with Xcode (OSX 10.13, Xcode 9.4),
I'm getting following warnings:

[code]
int value = m_config->Read( "my_key", 2 );
[/code]

[quote]
Implicit conversion loses integer precision: long to int
[/quote]

Is it possible to silence that warning somehow?

The value read is in the range of [1..4].

Thank you.

Vadim Zeitlin

unread,
Jan 16, 2023, 9:06:09 AM1/16/23
to wx-u...@googlegroups.com
On Mon, 16 Jan 2023 02:32:58 -0600 Igor Korot wrote:

IK> Hi, ALL,
IK> I'm using the latest release on all 3 major platforms.
IK>
IK> Compiling my code on Mac with Xcode (OSX 10.13, Xcode 9.4),
IK> I'm getting following warnings:
IK>
IK> [code]
IK> int value = m_config->Read( "my_key", 2 );
IK> [/code]
IK>
IK> [quote]
IK> Implicit conversion loses integer precision: long to int
IK> [/quote]
IK>
IK> Is it possible to silence that warning somehow?
IK>
IK> The value read is in the range of [1..4].

You can, of course, just add an explicit case after checking that the
value is in the expected range. You also can use

int value;
if ( m_config->Read("my_key", &value, 2) )
....

which would avoid the warning but you'd still need to check the range.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Igor Korot

unread,
Jan 16, 2023, 9:10:32 AM1/16/23
to wx-u...@googlegroups.com
Thx.
Reply all
Reply to author
Forward
0 new messages