You are not logged in.

#1 2009-07-24 22:40:43

Boris Bolgradov
Member
From: Bulgaria
Registered: 2008-07-27
Posts: 185

[Solved] C++ "invalid conversion from 'char*' to 'gint'"

Hi, it's me again.
I get this error when I try to compile the code:

xmms-control.cpp: In function 'int main(int, char**)':
xmms-control.cpp:10: error: invalid conversion from 'char*' to 'gint'

xmms_remote_set_main_volume() requires two gint parameters, but it can't convert it
Here's the code:

#include <xmms/xmmsctrl.h>
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{

gint session = 0;
gint vol = argv[1];

xmms_remote_set_main_volume(session, vol);

return 0;

}

Why is that?

*edit: The idea is to get a command-line argument and pass it to the xmms_blabla() function. If there's an alternative way to do this, tell me.

Last edited by Boris Bolgradov (2009-07-25 09:04:11)

Offline

#2 2009-07-25 08:52:48

WhiteMagic
Member
Registered: 2007-03-01
Posts: 85

Re: [Solved] C++ "invalid conversion from 'char*' to 'gint'"

As far as I can tell gint is a typedef from glib for a standard C int type (according to this [1]). If this is the case you could use atoi(argv[1]) to convert the input argument to an int / gint. That's pretty ugly I think but it might work as long as you only pass in integer values that atoi can handle.


[1] http://library.gnome.org/devel/glib/sta … .html#gint

Offline

#3 2009-07-25 09:03:59

Boris Bolgradov
Member
From: Bulgaria
Registered: 2008-07-27
Posts: 185

Re: [Solved] C++ "invalid conversion from 'char*' to 'gint'"

Thanks

Offline

Board footer

Powered by FluxBB