FAQ pointer q

S

Shane

Ive had a look at the FAQ for comp.lang.c, and I would have thought this was
a recurring question, but I didnt see it, so I'll ask :)
I am trying to transfer the contents of a gtk entry box into a
multi-dimensional array
But I keep getting the following warning

callbacks.c:212: warning: passing argument 1 of ‘gtk_entry_get_text’ from
incompatible pointer type
callbacks.c:212: warning: assignment makes integer from pointer without a
cast


The relevant code is

GtkWidget * A3 = lookup_widget(GTK_WIDGET(button), "A3");

saver[0][2] = gtk_entry_get_text(A3);

TIA

--
On two occasions I have been asked [by members of Parliament], 'Pray,
Mr. Babbage, if you put into the machine wrong figures, will the right
answers come out?' I am not able rightly to apprehend the kind of
confusion of ideas that could provoke such a question "

By: "Charles Babbage"

blog: http://shanes.dyndns.org
 
S

Shane

Shane said:
Ive had a look at the FAQ for comp.lang.c, and I would have thought this
was a recurring question, but I didnt see it, so I'll ask :)
I am trying to transfer the contents of a gtk entry box into a
multi-dimensional array
But I keep getting the following warning

callbacks.c:212: warning: passing argument 1 of ‘gtk_entry_get_text’ from
incompatible pointer type
callbacks.c:212: warning: assignment makes integer from pointer without a
cast


The relevant code is

GtkWidget * A3 = lookup_widget(GTK_WIDGET(button), "A3");

saver[0][2] = gtk_entry_get_text(A3);

TIA

er. the question is, how do I stop this warning, and why am I getting it in
the first place

--
Professor Fransworth: [In an empty classroom] ...and therefore, by process
of elimination, the electron must taste like grape-ade.
Fry: Sorry, I overslept.
Professor Fransworth: Until 5 p.m.?!

blog: http://shanes.dyndns.org
 
I

Ian Collins

Shane said:
Ive had a look at the FAQ for comp.lang.c, and I would have thought this was
a recurring question, but I didnt see it, so I'll ask :)
I am trying to transfer the contents of a gtk entry box into a
multi-dimensional array
But I keep getting the following warning

callbacks.c:212: warning: passing argument 1 of ‘gtk_entry_get_text’ from
incompatible pointer type
callbacks.c:212: warning: assignment makes integer from pointer without a
cast


The relevant code is

GtkWidget * A3 = lookup_widget(GTK_WIDGET(button), "A3");

saver[0][2] = gtk_entry_get_text(A3);
What are the prototypes of the these functions?
 
S

Shane

Ian said:
What are the prototypes of the these functions?
saver[0][2] = gtk_entry_get_text(A3);

gtk_entry_get_text ()

gchar* gtk_entry_get_text (GtkEntry *entry);

Retrieve the contents of the entry widget. The returned pointer points to
internally allocated storage in the widget and must not be freed, modified
or stored. For this reason, this function is deprecated. Use
gtk_editable_get_chars() instead.

entry : a GtkEntry.
Returns : the pointer the the contents of the text widget as a string.


--
Bender: Fine. I'll go build my own lunar lander! With blackjack! And
hookers! In fact, forget the lunar lander and the blackjack! Ah, screw the
whole thing.

blog: http://shanes.dyndns.org
 
M

Martin Ambuhl

Shane said:
Ive had a look at the FAQ for comp.lang.c, and I would have thought this was
a recurring question, but I didnt see it, so I'll ask :)
I am trying to transfer the contents of a gtk entry box into a
multi-dimensional array
But I keep getting the following warning

callbacks.c:212: warning: passing argument 1 of ‘gtk_entry_get_text’ from
incompatible pointer type
callbacks.c:212: warning: assignment makes integer from pointer without a
cast

The relevant code is
GtkWidget * A3 = lookup_widget(GTK_WIDGET(button), "A3");
saver[0][2] = gtk_entry_get_text(A3);

No, the relevant code would include the declaration of saver and the
prototype of gtk_entry_get_text, which appears to take an argument of a
type other than 'GtkWidget *', and appears to return a pointer which you
are attempting to assign to what appears to be an integer. But guessing
is silly: you chose to hide the relevant details, so live with it.
 
S

Shane

Ian said:
Shane said:
Ian Collins wrote:

What are the prototypes of the these functions?


saver[0][2] = gtk_entry_get_text(A3);
So what is saver? It isn't an array of int* by any chance?
gtk_entry_get_text ()

gchar* gtk_entry_get_text (GtkEntry *entry);

Retrieve the contents of the entry widget. The returned pointer points to
internally allocated storage in the widget and must not be freed,
modified or stored. For this reason, this function is deprecated. Use
gtk_editable_get_chars() instead.

entry : a GtkEntry.
Returns : the pointer the the contents of the text widget as a
string.


Sorry, I cannot find any docs related to saver (hence why I didnt post any)
I was following a tutorial on GTK, in a roundabout way, and have since been
told that I was using a deprecated tool (Glade)
I am completely lost atm, and have dropped that idea, and now looking at
KDevelop
 
S

Shane

Martin said:
Shane said:
Ive had a look at the FAQ for comp.lang.c, and I would have thought this
was a recurring question, but I didnt see it, so I'll ask :)
I am trying to transfer the contents of a gtk entry box into a
multi-dimensional array
But I keep getting the following warning

callbacks.c:212: warning: passing argument 1 of ‘gtk_entry_get_text’ from
incompatible pointer type
callbacks.c:212: warning: assignment makes integer from pointer without a
cast

The relevant code is
GtkWidget * A3 = lookup_widget(GTK_WIDGET(button), "A3");
saver[0][2] = gtk_entry_get_text(A3);

No, the relevant code would include the declaration of saver and the
prototype of gtk_entry_get_text, which appears to take an argument of a
type other than 'GtkWidget *', and appears to return a pointer which you
are attempting to assign to what appears to be an integer. But guessing
is silly: you chose to hide the relevant details, so live with it.


My god theres always one isnt there
 
R

Richard Heathfield

Shane said:
Martin said:
Shane said:
The relevant code is
GtkWidget * A3 = lookup_widget(GTK_WIDGET(button), "A3");
saver[0][2] = gtk_entry_get_text(A3);

No, the relevant code would include the declaration of saver and the
prototype of gtk_entry_get_text, which appears to take an argument of a
type other than 'GtkWidget *', and appears to return a pointer which you
are attempting to assign to what appears to be an integer. But guessing
is silly: you chose to hide the relevant details, so live with it.


My god theres always one isnt there

See below.

But first, Shane, I think you'd be wise to drop glade *and* to drop
KDevelop, *and* to drop your Sudoku solver ("How the hell does he know
that?" I hear you say... well, I have my ways of knowing these things), and
just focus on learning C.

You're biting off more than you can chew, this early in your language
learning. There are lots of interesting projects you can do that don't
involve GUI work. You are just giving yourself too much complexity in one
lump, and you won't know whether any given problem arises from your
ignorance of the language, of the tool, or of the task. Divide and conquer.
Learn one hard thing at a time.

Now, about Martin. He's what we call an "expert". He knows his stuff, and
he's a fabulous, albeit somewhat grumpy, bloke. He used to just be
fabulous, but then a trillion newbies came along, asking much a quadrillion
questions, and very often these questions - and the way in which they were
asked - betrayed not just a lack of knowledge (which you expect in a
newbie), but also a lack of thought and indeed courtesy. And so, by turns,
he became grumpy as well as fabulous.

If you want people to give *you* the benefit of the doubt, I suggest you
start your sojourn in this newsgroup by giving others that same benefit.
After all, everything Martin said is perfectly correct - you did fail to
provide the relevant code, which would have made it far easier to explain
to you what precisely your problem was.
 
S

Shane

Richard said:
Shane said:
Martin said:
Shane wrote:

The relevant code is
GtkWidget * A3 = lookup_widget(GTK_WIDGET(button), "A3");
saver[0][2] = gtk_entry_get_text(A3);

No, the relevant code would include the declaration of saver and the
prototype of gtk_entry_get_text, which appears to take an argument of a
type other than 'GtkWidget *', and appears to return a pointer which you
are attempting to assign to what appears to be an integer. But guessing
is silly: you chose to hide the relevant details, so live with it.


My god theres always one isnt there

See below.

But first, Shane, I think you'd be wise to drop glade *and* to drop
KDevelop, *and* to drop your Sudoku solver ("How the hell does he know
that?" I hear you say... well, I have my ways of knowing these things),
and just focus on learning C.

You're biting off more than you can chew, this early in your language
learning. There are lots of interesting projects you can do that don't
involve GUI work. You are just giving yourself too much complexity in one
lump, and you won't know whether any given problem arises from your
ignorance of the language, of the tool, or of the task. Divide and
conquer. Learn one hard thing at a time.

Now, about Martin. He's what we call an "expert". He knows his stuff, and
he's a fabulous, albeit somewhat grumpy, bloke. He used to just be
fabulous, but then a trillion newbies came along, asking much a
quadrillion questions, and very often these questions - and the way in
which they were asked - betrayed not just a lack of knowledge (which you
expect in a newbie), but also a lack of thought and indeed courtesy. And
so, by turns, he became grumpy as well as fabulous.

If you want people to give *you* the benefit of the doubt, I suggest you
start your sojourn in this newsgroup by giving others that same benefit.
After all, everything Martin said is perfectly correct - you did fail to
provide the relevant code, which would have made it far easier to explain
to you what precisely your problem was.


A gruff attitude does nobody any favours, I posted what I *thought* was the
relevant code, rather than post the several thousand lines of code that
made up the application.

$ wc -l *
1678 aclocal.m4
0 AUTHORS
159 autogen.sh
wc: autom4te.cache: Is a directory
0 autom4te.cache
0 ChangeLog
1466 config.guess
74 config.h
73 config.h.in
619 config.log
1089 config.status
1579 config.sub
7018 configure
31 configure.in
340 COPYING
182 INSTALL
269 install-sh
401 Makefile
30 Makefile.am
401 Makefile.in
198 missing
111 mkinstalldirs
0 NEWS
wc: po: Is a directory
0 po
1947 project2.glade
1947 project2.glade.bak
8 project2.gladep
8 project2.gladep.bak
0 README
wc: src: Is a directory
0 src
1 stamp-h
1 stamp-h.in
19630 total

That isnt including the subdirectorys

Im more than aware of the damage asking stupid questions does, and for my
part in that I apologise, but in my defence I made some effort and tried to
keep it concise

As I have a rather hard head I will keep on with this attempt with
sudoku/gui/c
Even if I am ignored on IRC ;-)
 
I

Ian Collins

Shane said:
A gruff attitude does nobody any favours, I posted what I *thought* was the
relevant code, rather than post the several thousand lines of code that
made up the application.
All that is asked for here is an example that compiles and demonstrates
your problem. Otherwise people have to guess, which as Martin correctly
points out, is silly.

Often building an example reveals the problem.

It's called helping us to help you.
 
R

Richard Heathfield

Shane said:

As I have a rather hard head I will keep on with this attempt with
sudoku/gui/c

I think that's a mistake, but hey, it's your funeral, not mine.

Ask C questions here.

Sudoku questions will probably be tolerated in rec.puzzles, although don't
quote me on that.

GTK questions - er, they'll have their own newsgroup, no doubt, but I don't
know what it is. Ask in comp.os.linux.development.apps in the first
instance, and no doubt they'll set you right.

And for programming questions, comp.programming is your friend.

And how do you decide whether your problem is a C question, a Sudoku
question, a GTK question, or a general algorithmic question? Or maybe it's
a tangle of two or three of them. Unravelling such nightmares will not be
fun, and it will not build up your confidence.

Don't say I didn't warn you.
 
M

Martin Ambuhl

Shane said:
A gruff attitude does nobody any favours, I posted what I *thought* was the
relevant code, rather than post the several thousand lines of code that
made up the application.

There is no "gruff attitude" in asking that you post the code relevant
to your problem. There is no need to show us your directory listing.
Look at your original post:
callbacks.c:212: warning: passing argument 1 of ‘gtk_entry_get_text’ from
incompatible pointer type
callbacks.c:212: warning: assignment makes integer from pointer without a
cast


The relevant code is

GtkWidget * A3 = lookup_widget(GTK_WIDGET(button), "A3");

saver[0][2] = gtk_entry_get_text(A3);

Now the first diagnostic tells you that the type of the argument to
get_entry_get_ext (which is A3) is of the wrong type. How could
*anyone* imagine that the type of the argument expected would not be
relevant?

The second diagnostic tells you that get_entry_get_text returns a
pointer of some type, which you are trying to store in some integral
type. How could *anyone* imagine that the type of saver and the type
returned by gtk_entry_get_text would not be relevant.

If you thought you had posted the relevant code, then you clearly did
not even bother to read the diagnostics or, if you did read the
diagnostics, you are grossly incompetent.
 
D

Default User

If you thought you had posted the relevant code, then you clearly did
not even bother to read the diagnostics or, if you did read the
diagnostics, you are grossly incompetent.


See, not THAT is gruff.




Brian
 
R

Richard Heathfield

Default User said:
See, not THAT is gruff.

As o'er my latest book I pored,
Enjoying it immensely
I suddenly exclaimed 'Good Lord!'
And gripped the volume tensely.
'Golly!' I cried. I writhed in pain.
'They've done it on me once again!'
And furrows creased my brow.
I'd written (which I thought quite good)
'Ruth, ripening into womenhood,
Was now a girl who knocked men flat
And frequently got whistled at,'
And some vile, careless, casual gook
Had spoiled the best thing in the book
By printing 'not' (Yes, 'not,' great Scott!)
When I had written 'now'.

On murder in the first degree
The Law, I knew, is rigid:
Its attitude, if A kills B,
To A is always frigid.
It counts it not a trivial slip
If on behalf of authorship
You liquidate compositors.
This kind of conduct it abhors
And seldom will allow.
Nevertheless, I deemed it best
And in the public interest
To buy a gun, to oil it well,
Inserting what is called a shell,
And go and pot
With sudden shot
This printer who had printed 'not'
When I had written 'now'.
I tracked the bounder to his den
Through private information:
I said 'Good afternoon' and then
Explained the situation:

'I'm not a fussy man,' I said.
'I smile when you put "rid" for "red"
And "bad" for "bed" and "hoad" for "head"
And "bolge" instead of "bough".
When "wone" appears in lieu of "wine"
Or if you alter "Cohn" to "Schine",
I never make a row.
I know how easy errors are.
But this time you have gone too far
By printing "not" when you knew what
I really wrote was "now".
'Prepare,' I said, 'to meet your God
Or, as you'd say, your Goo or Bod
Or possibly your Gow.'

A few weeks later into court
I came to stand my trial.
The judge was quite a decent sort,
He said 'Well cocky, I'll
Be passing sentence in a jiff,
And so, my poor unhappy stiff,
If you have anything to say,
Now is the moment. Fire away.
You have?'
I said 'And how!
Me lud, the facts I don't dispute.
I did, I own it freely, shoot
This printer through the collar stud.
What else could I have done, me lud?
He'd printed "not"...'
The judge said '/What/!
When you had written "now"?
God bless my soul!
Gadzooks!' said he.
'The blighters did that once to me.
A dirty trick, I trow.
I hereby quash and override
The jury's verdict. Gosh!' he cried.
'Give me your hand. Yes I insist,
You splendid fellow! Case dismissed.'
(Cheers, and a Voice 'Wow-wow!')

A statue stands against the sky,
Lifelike and rather pretty.
'Twas recently erected by
The P.E.N. committee.
And many a passer-by is stirred,
For on the plinth, if that's the word,
In golden letters you may read
'This is the man who did the deed.
His hand set to the plough,
He did not sheathe the sword, but got
A gun at great expense and shot
The human blot who'd printed "not"
When he had written "now".
He acted with no thought of self,
Not for advancement, not for pelf,
But just because it made him hot
To think the man had printed "not"
When he had written "now".'

-- P G Wodehouse
 
K

Kenneth Brody

Shane said:
Ian said:
What are the prototypes of the these functions?
saver[0][2] = gtk_entry_get_text(A3);

gtk_entry_get_text ()

gchar* gtk_entry_get_text (GtkEntry *entry);
[...]

The code getting the error (from your original post):

GtkWidget * A3 = lookup_widget(GTK_WIDGET(button), "A3");

saver[0][2] = gtk_entry_get_text(A3);

You are passing a "GtkWidget *", while the prototype says the
function expects "GtkEntry *".

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:[email protected]>
 
D

Default User

Richard said:
Default User said:

lines >> > of code that made up the application.
*sigh*

By printing 'not' (Yes, 'not,' great Scott!)
When I had written 'now'.

Oh well. One of these days I'll look into that poorfreading business.



Brian
 
R

Richard Heathfield

Sri Ragaventhirar said:
GtkWidget * A3 = lookup_widget(GTK_WIDGET(button), "A3");

saver[0][2] = gtk_entry_get_text(A3);

use :
strcpy(saver,gtk_entry_get_text());

No, don't follow that advice. You can't meaningfully pass an int (*)[9] to a
function that actually expects a char *.

Sri - please don't give advice unless you know it is correct. Thank you.
 
S

Sri Ragaventhirar

use :
strcpy(saver,gtk_entry_get_text());

No, don't follow that advice. You can't meaningfully pass an int (*)[9] to a
function that actually expects a char *.

Sri - please don't give advice unless you know it is correct. Thank you.

sorry. i thought saver was a char array.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top