473,403 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

FAQ pointer q

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

Dec 12 '06 #1
19 1424
Shane wrote:
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

Dec 12 '06 #2
Shane wrote:
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?

--
Ian Collins.
Dec 12 '06 #3
Ian Collins wrote:
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

Dec 12 '06 #4
Shane wrote:
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.


--
Ian Collins.
Dec 12 '06 #5
Shane wrote:
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.
Dec 12 '06 #6
Ian Collins wrote:
Shane wrote:
>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

--
Robot Devil: You can't just have your characters announce how they feel!
That makes me feel angry!

blog: http://shanes.dyndns.org

Dec 12 '06 #7
Martin Ambuhl wrote:
Shane wrote:
>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

--
Fry: That doesn't look like an L, unless you count lowercase.
Bender: You know we don't!

blog: http://shanes.dyndns.org

Dec 12 '06 #8
Shane said:
Martin Ambuhl wrote:
>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.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Dec 12 '06 #9
Richard Heathfield wrote:
Shane said:
>Martin Ambuhl wrote:
>>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 ;-)
--
Bender: Bodies are for hookers and fat people.

blog: http://shanes.dyndns.org

Dec 12 '06 #10
Shane wrote:
>
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.

--
Ian Collins.
Dec 12 '06 #11
Shane said:

<snip>
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.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Dec 12 '06 #12
Shane wrote:
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.
Dec 12 '06 #13
Amblin' Marty Ambuhl wrote:
Shane wrote:
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.
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
Dec 12 '06 #14
Default User said:
Amblin' Marty Ambuhl wrote:
>Shane wrote:
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.
>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.
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

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Dec 12 '06 #15
Richard Heathfield wrote:
Default User said:
Amblin' Marty Ambuhl wrote:
Shane wrote:

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.
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.
*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

Dec 12 '06 #16
Shane wrote:
>
Ian Collins wrote:
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:Th*************@gmail.com>

Dec 12 '06 #17
GtkWidget * A3 = lookup_widget(GTK_WIDGET(button), "A3");
>
saver[0][2] = gtk_entry_get_text(A3);
use :
strcpy(saver,gtk_entry_get_text());

Dec 13 '06 #18
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.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Dec 13 '06 #19
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.

Dec 14 '06 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Carsten Spieß | last post by:
Hello all, i have a problem with a template constructor I reduced my code to the following (compiled with gcc 2.7.2) to show my problem: // a base class class Base{}; // two derived...
110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
3
by: Bruno van Dooren | last post by:
Hi All, i have some (3) different weird pointer problems that have me stumped. i suspect that the compiler behavior is correct because gcc shows the same results. ...
35
by: tuko | last post by:
Hello kind people. Can someone explain please the following code? /* Create Storage Space For The Texture */ AUX_RGBImageRec *TextureImage; /* Line 1*/ /* Set The Pointer To NULL...
16
by: junky_fellow | last post by:
According to Section A6.6 Pointers and Integers (k & R) " A pointer to one type may be converted to a pointer to another type. The resulting pointer may cause addressing exceptions if the...
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
16
by: aegis | last post by:
Given the following: int a = 10; int *p; void *p1; unsigned char *p2; p = &a;
23
by: bluejack | last post by:
Ahoy... before I go off scouring particular platforms for specialized answers, I thought I would see if there is a portable C answer to this question: I want a function pointer that, when...
69
by: fieldfallow | last post by:
Hello all, Before stating my question, I should mention that I'm fairly new to C. Now, I attempted a small demo that prints out the values of C's numeric types, both uninitialised and after...
8
by: Martin Jørgensen | last post by:
Hi, "C primer plus" p.382: Suppose we have this declaration: int (*pa); int ar1; int ar2; int **p2;
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.