Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #15186 > unrolled thread
| Started by | someone <newsboost@gmail.com> |
|---|---|
| First post | 2011-12-29 09:11 -0800 |
| Last post | 2012-01-25 17:39 -0800 |
| Articles | 16 on this page of 36 — 16 participants |
Back to article view | Back to comp.lang.c
passing static 2D array to function - not fully working like I hoped for... someone <newsboost@gmail.com> - 2011-12-29 09:11 -0800
Re: passing static 2D array to function - not fully working like I hoped for... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-29 17:27 +0000
Re: passing static 2D array to function - not fully working like I hoped for... someone <newsboost@gmail.com> - 2011-12-29 10:55 -0800
Re: passing static 2D array to function - not fully working like I hoped for... jt@toerring.de (Jens Thoms Toerring) - 2011-12-29 17:34 +0000
Re: passing static 2D array to function - not fully working like I hoped for... someone <newsboost@gmail.com> - 2011-12-29 11:03 -0800
Re: passing static 2D array to function - not fully working like I hoped for... jt@toerring.de (Jens Thoms Toerring) - 2011-12-29 19:38 +0000
Re: passing static 2D array to function - not fully working like I hoped for... "BartC" <bc@freeuk.com> - 2011-12-29 23:19 +0000
Re: passing static 2D array to function - not fully working like I hoped for... "BartC" <bc@freeuk.com> - 2011-12-31 11:29 +0000
Re: passing static 2D array to function - not fully working like I hoped for... 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-29 17:26 -0800
Re: passing static 2D array to function - not fully working like I hoped for... Keith Thompson <kst-u@mib.org> - 2011-12-29 11:58 -0800
Re: passing static 2D array to function - not fully working like I hoped for... Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-25 17:45 -0800
Re: passing static 2D array to function - not fully working like I hoped for... Kaz Kylheku <kaz@kylheku.com> - 2012-01-26 02:08 +0000
Re: passing static 2D array to function - not fully working like I hoped for... James Kuyper <jameskuyper@verizon.net> - 2011-12-29 15:35 -0500
Re: passing static 2D array to function - not fully working like I hoped for... Keith Thompson <kst-u@mib.org> - 2011-12-29 13:25 -0800
Re: passing static 2D array to function - not fully working like I hoped for... "io_x" <a@b.c.invalid> - 2011-12-31 16:32 +0100
Re: passing static 2D array to function - not fully working like I hoped for... 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-31 15:10 -0800
Re: passing static 2D array to function - not fully working like I hoped for... "osmium" <r124c4u102@comcast.net> - 2011-12-31 18:03 -0600
Re: passing static 2D array to function - not fully working like I hoped for... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-29 20:37 +0000
Re: passing static 2D array to function - not fully working like I hoped for... jgk@panix.com (Joe keane) - 2012-01-03 15:48 +0000
Re: passing static 2D array to function - not fully working like I hoped for... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-03 16:47 +0000
Re: passing static 2D array to function - not fully working like I hoped for... Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-01-05 22:31 +0200
Re: passing static 2D array to function - not fully working like I hoped for... Nobody <nobody@nowhere.com> - 2011-12-31 09:23 +0000
Re: passing static 2D array to function - not fully working like I hoped for... Keith Thompson <kst-u@mib.org> - 2011-12-31 11:04 -0800
Re: passing static 2D array to function - not fully working like I hoped for... Nobody <nobody@nowhere.com> - 2012-01-01 08:20 +0000
Re: passing static 2D array to function - not fully working like I hoped for... Barry Schwarz <schwarzb@dqel.com> - 2011-12-29 09:49 -0800
Re: passing static 2D array to function - not fully working like I hoped for... someone <newsboost@gmail.com> - 2011-12-29 11:13 -0800
Re: passing static 2D array to function - not fully working like I hoped for... Seebs <usenet-nospam@seebs.net> - 2011-12-29 19:22 +0000
Re: passing static 2D array to function - not fully working like I hoped for... someone <newsboost@gmail.com> - 2011-12-29 13:29 -0800
Re: passing static 2D array to function - not fully working like I hoped for... Seebs <usenet-nospam@seebs.net> - 2011-12-29 21:42 +0000
Re: passing static 2D array to function - not fully working like I hoped for... someone <newsboost@gmail.com> - 2011-12-29 15:28 -0800
Re: passing static 2D array to function - not fully working like I hoped for... Keith Thompson <kst-u@mib.org> - 2011-12-29 14:46 -0800
Re: passing static 2D array to function - not fully working like I hoped for... James Kuyper <jameskuyper@verizon.net> - 2011-12-29 18:29 -0500
Re: passing static 2D array to function - not fully working like I hoped for... Seebs <usenet-nospam@seebs.net> - 2011-12-30 00:03 +0000
Re: passing static 2D array to function - not fully working like I hoped for... James Kuyper <jameskuyper@verizon.net> - 2011-12-29 21:30 -0500
Re: passing static 2D array to function - not fully working like I hoped for... Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-25 17:47 -0800
Re: passing static 2D array to function - not fully working like I hoped for... Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-25 17:39 -0800
Page 2 of 2 — ← Prev page 1 [2]
| From | Phil Carmody <thefatphil_demunged@yahoo.co.uk> |
|---|---|
| Date | 2012-01-05 22:31 +0200 |
| Message-ID | <87zke1x55v.fsf@bazspaz.fatphil.org> |
| In reply to | #15374 |
jgk@panix.com (Joe keane) writes: > In article <0.dcfd9b0b4291e1147cd8.20111229203726GMT.87vcoz9ks9.fsf@bsb.me.uk>, > Ben Bacarisse <ben.usenet@bsb.me.uk> wrote: > >The cast is superfluous. > > Automatic conversion of 'double' to 'float' is one thing that i would > rather not have in the language. Use your compiler flags to turn it into a warning, and turn warnings into fatal errors? Phil -- Unix is simple. It just takes a genius to understand its simplicity -- Dennis Ritchie (1941-2011), Unix Co-Creator
[toc] | [prev] | [next] | [standalone]
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Date | 2011-12-31 09:23 +0000 |
| Message-ID | <pan.2011.12.31.09.23.54.442000@nowhere.com> |
| In reply to | #15199 |
On Thu, 29 Dec 2011 11:03:46 -0800, someone wrote: > Of some reason, floats seem to be widely used with opengl... Don' ask > me why - I don't know. OpenGL itself either provides both float and double versions, or just a double version. Code which uses OpenGL tends to use double because the extra precision is usually either entirely pointless (if the hardware only uses single precision) or mostly pointless (any difference will be imperceptible), and tends to harm performance (twice the memory consumption, either twice or four times as many GPU cycles).
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2011-12-31 11:04 -0800 |
| Message-ID | <ln7h1c7ec3.fsf@nuthaus.mib.org> |
| In reply to | #15240 |
Nobody <nobody@nowhere.com> writes:
> On Thu, 29 Dec 2011 11:03:46 -0800, someone wrote:
>
>> Of some reason, floats seem to be widely used with opengl... Don' ask
>> me why - I don't know.
>
> OpenGL itself either provides both float and double versions, or just a
> double version.
>
> Code which uses OpenGL tends to use double because the extra precision is
------
> usually either entirely pointless (if the hardware only uses single
> precision) or mostly pointless (any difference will be imperceptible), and
> tends to harm performance (twice the memory consumption, either twice or
> four times as many GPU cycles).
Did you mean "Code which uses OpenGL tends to use float ..."?
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Date | 2012-01-01 08:20 +0000 |
| Message-ID | <pan.2012.01.01.08.20.27.180000@nowhere.com> |
| In reply to | #15256 |
On Sat, 31 Dec 2011 11:04:12 -0800, Keith Thompson wrote: >> Code which uses OpenGL tends to use double because the extra precision is > ------ >> usually either entirely pointless (if the hardware only uses single >> precision) or mostly pointless (any difference will be imperceptible), and >> tends to harm performance (twice the memory consumption, either twice or >> four times as many GPU cycles). > > Did you mean "Code which uses OpenGL tends to use float ..."? Yes. Either that or "... tends to avoid double ...".
[toc] | [prev] | [next] | [standalone]
| From | Barry Schwarz <schwarzb@dqel.com> |
|---|---|
| Date | 2011-12-29 09:49 -0800 |
| Message-ID | <qu9pf7lb9892v51fmdfr082hppso4spvdq@4ax.com> |
| In reply to | #15186 |
On Thu, 29 Dec 2011 09:11:08 -0800 (PST), someone <newsboost@gmail.com> wrote: >Hi all > >Noob question: > >----------------------------------------------------------------------------- >typedef float GLfloat; // float = GLfloat > >void setBezierPoint(const double &x, const double &y, const double &z, > const int &P, GLfloat bezierCTRpts[][3]) snip You are looking fro comp.lang.c++. Down the hall, turn left at the vending machine, third door on the right. -- Remove del for email
[toc] | [prev] | [next] | [standalone]
| From | someone <newsboost@gmail.com> |
|---|---|
| Date | 2011-12-29 11:13 -0800 |
| Message-ID | <aa63c87c-16f7-4228-b965-cb144c00fd54@q9g2000yqe.googlegroups.com> |
| In reply to | #15192 |
On Dec 29, 6:49 pm, Barry Schwarz <schwa...@dqel.com> wrote: > On Thu, 29 Dec 2011 09:11:08 -0800 (PST), someone > > <newsbo...@gmail.com> wrote: > >Hi all > > >Noob question: > > >----------------------------------------------------------------------------- > >typedef float GLfloat; // float = GLfloat > > >void setBezierPoint(const double &x, const double &y, const double &z, > > const int &P, GLfloat bezierCTRpts[][3]) > > snip > > You are looking fro comp.lang.c++. No I'm not.
[toc] | [prev] | [next] | [standalone]
| From | Seebs <usenet-nospam@seebs.net> |
|---|---|
| Date | 2011-12-29 19:22 +0000 |
| Message-ID | <slrnjfph92.pfq.usenet-nospam@guild.seebs.net> |
| In reply to | #15201 |
On 2011-12-29, someone <newsboost@gmail.com> wrote: >> You are looking fro comp.lang.c++. > No I'm not. I'm curious as to why you say this. Your code is obviously C++. Nothing similar to it has ever been part of C. Granted that a similar question could apply to C, the mere fact that you're using references means that the rules for what you're doing are certainly going to be different. So the question is: Why *aren't* you looking for a C++ group? Do you think that they would be unable to answer your question? If so, why? -s -- Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! I am not speaking for my employer, although they do rent some of my opinions.
[toc] | [prev] | [next] | [standalone]
| From | someone <newsboost@gmail.com> |
|---|---|
| Date | 2011-12-29 13:29 -0800 |
| Message-ID | <aac82e18-bb3f-4cc0-ba06-6d89aef193f4@q8g2000yqa.googlegroups.com> |
| In reply to | #15204 |
On Dec 29, 8:22 pm, Seebs <usenet-nos...@seebs.net> wrote: > On 2011-12-29, someone <newsbo...@gmail.com> wrote: > > >> You are looking fro comp.lang.c++. > > No I'm not. > > I'm curious as to why you say this. Your code is obviously C++. Nothing > similar to it has ever been part of C. I'm saying it because it's true. > Granted that a similar question could apply to C, the mere fact that you're > using references means that the rules for what you're doing are certainly > going to be different. > > So the question is: Why *aren't* you looking for a C++ group? Do you think > that they would be unable to answer your question? If so, why? I already explained this, pretty clear I think. What interest do you have in whether or not any other C++ group would (or would not) be "unable to answer the question"? Don't worry about that. I think I'll have to move on with my own project now, sorry I don't have so much time to continue... To those who want to continue in this thread: Please go on with your "C vs. C++" discussions without me and have a nice evening. I don't think I asked for this, but feel free to continue and e.g. keep repeating the same things somebody before you already wrote a lot of times (like: "this is not C, why don't you understand it etc..." and other similar comments). Thanks a lot to those who understood the C in the question and spend time answering the C-question. Feel free to continue without me, Peter Seebach and others (and feel free to repeat yourselves again), thanks for your time - I think I'll not answer more in this thread, because then people will call me a troll or similar and I can find better things to do in my spare time.
[toc] | [prev] | [next] | [standalone]
| From | Seebs <usenet-nospam@seebs.net> |
|---|---|
| Date | 2011-12-29 21:42 +0000 |
| Message-ID | <slrnjfpnmk.spb.usenet-nospam@guild.seebs.net> |
| In reply to | #15212 |
On 2011-12-29, someone <newsboost@gmail.com> wrote: > I'm saying it because it's true. Yes, I was asking *why* it's true. Why are you not looking for a C++ group for a question which is clearly about C++? The thing is... The languages are similar, but if you repeatedly ask questions in a C group because you think they probably apply to C, and you are actually writing C++, you're gonna get burned on the differences, which people may not think to bring up. But whatever. You seem uninterested in the possibility that there are differences, you're dismissive and rude, and you've said you aren't interested in what people have to say if they aren't blithely answering your questions without any hint of reference to the possibility of differences between C and C++ which would affect how your code will work. Good luck with that. -s -- Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! I am not speaking for my employer, although they do rent some of my opinions.
[toc] | [prev] | [next] | [standalone]
| From | someone <newsboost@gmail.com> |
|---|---|
| Date | 2011-12-29 15:28 -0800 |
| Message-ID | <8854566f-5e2a-402d-84e2-9e85f0f5fb83@k28g2000yqn.googlegroups.com> |
| In reply to | #15213 |
On Dec 29, 10:42 pm, Seebs <usenet-nos...@seebs.net> wrote: > On 2011-12-29, someone <newsbo...@gmail.com> wrote: > > > I'm saying it because it's true. > > Yes, I was asking *why* it's true. Why are you not looking for a C++ group > for a question which is clearly about C++? Because the question is clearly about C! The question was a C- question. Understand it or not - hence the group. What part of it is too hard to understand? I'm afraid I'm making a big mistake just by answering you now, however I feel I must correct you on the issue you're complaining about: "the question is clearly about C++". Please stop wasting more time by repeating that the question was not a C- question, when I think it was/is... This is the last answer you (and others who keep repeating the same) will get from me - I promise! > The thing is... The languages are similar, but if you repeatedly ask questions Eerhm, "repeatedly"... Stop wasting my time with this shit, thank you. How many "repeatedly times" have you counted? > in a C group because you think they probably apply to C, and you are actually > writing C++, you're gonna get burned on the differences, which people may not > think to bring up. Eerhm, I think I've read the same thing over and over again in this thread. Please stop repeating what has already been written. > But whatever. You seem uninterested in the possibility that there are > differences, you're dismissive and rude, and you've said you aren't interested > in what people have to say if they aren't blithely answering your questions > without any hint of reference to the possibility of differences between C > and C++ which would affect how your code will work. Good luck with that. That is the stupidiest thing I've read in the whole thread, causing this to be my final answer. 1) No, I'm not "uninterested in the possibility that there are differences". I've never written that anywhere. I read the ontopic answers with great interest. 2) So just call me "dismissive and rude" because I don't want to hear/ read all your C++ ideas in a non-C++ newsgroup (I think I should take that as a complement, because C++ is offtopic here and you keep insisting on being offtopic, as far as I can judge). 3) No, I never said "you aren't interested in what people have to say if they aren't blithely answering your questions without any hint of reference to the possibility of differences between C and C++ which would affect how your code will work" - the fact that you're postulating that, makes me completely sure that my time is up now and I've already spend too much time on you by now. 4) I believe I honestly already expressed my gratitude to everyone in this thread who has helped me and spend time on trying to help me. and that is practically everyone. Besides, I've read and understood what everyone wrote and I read it with great interest (except for the postings that looks just like your post, someone who don't understand to ignore cout and pass-by-reference no matter if they've been told one million times or not). That's all I think/feel I can do: To express my gratitude and we cannot expect anything else here on usenet, I believe. 5) What I don't like (and reason for me to correct on you), is people trying to convince somebody (or themself/themselves) that I'm "dismissive and rude" etc, just because I asked a C-question here (with 2 mistakes I think, I never said the code was 100% correct, I wrote: "If you like/ask for it, perhaps I can make a minimal working example", meaning that the code was only pseudo-code). It seems like you have an *extremely* hard time understanding, that I was interested in the C-solution, relevant to C-coding and not the C++-solution, which is offtopic here. Sorry to say that I cannot (and think it's a waste of time) to answer more questions in this thread. Those who received my gratitude should know that I think it's great that they understood the C-question and I want to thank for that, for that for the last time now. [over and out - au revoir]
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2011-12-29 14:46 -0800 |
| Message-ID | <lnhb0jxag9.fsf@nuthaus.mib.org> |
| In reply to | #15212 |
someone <newsboost@gmail.com> writes:
> On Dec 29, 8:22 pm, Seebs <usenet-nos...@seebs.net> wrote:
[...]
>> So the question is: Why *aren't* you looking for a C++ group? Do you think
>> that they would be unable to answer your question? If so, why?
>
> I already explained this, pretty clear I think.
[...]
> Thanks a lot to those who understood the C in the question and spend
> time answering the C-question.
[...]
What we're trying to explain to you is that C and C++, though
they're closely related, are different languages, and even the
C-like subset of C++ has some quite subtle differences from C.
We're glad to answer questions about C here. The folks over in
comp.lang.c++ are glad to answer questions about C++, even for
programs that are mostly written in the C-like subset of that
language.
But if you post something here that's mostly C, but using
C++-specific features, then there's always the very real possibility
that some C vs. C++ incompatibility could be (part of) the cause
of the problem you're asking about. Many of us here are not C++
experts, and we have no idea whether *you're* familiar enough with
the issues that we can safely ignore them and concentrate on the
C-specific parts of your code.
If you can take the time to write your code so it's in pure C,
it will make it easier for us to help you -- which, after all,
is what we're trying to do here.
Or if you want to ask about code that can only be compiled with a
C++ compiler (and it's perfectly ok to do that), comp.lang.c++ is a
better place to ask about it.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2011-12-29 18:29 -0500 |
| Message-ID | <4EFCF7E2.4030105@verizon.net> |
| In reply to | #15204 |
On 12/29/2011 02:22 PM, Seebs wrote: > On 2011-12-29, someone <newsboost@gmail.com> wrote: >>> You are looking fro comp.lang.c++. > >> No I'm not. > > I'm curious as to why you say this. Your code is obviously C++. Nothing > similar to it has ever been part of C. His answer to Ben with the header Date: Thu, 29 Dec 2011 10:55:20 -0800 (PST) said: > I forgot that &(var) is C++, however I think that is the only thing I > forgot... I even added a typedef in the beginning to avoid someone > telling me that GLfloat "is not part of the C-standard, hence not a > question for this group"... > > I am/was looking for the "C-answer", not a "C++-answer", so that's why > I thought it is better to post to here... It's not entirely clear from the above what's going on, but my interpretation is that he had C++ code that he wanted to move to C, and also had some questions about a desired modification of the code. He tried to translate it to C code, but forgot a couple of things that should have been changed. The remaining C++ features of the code are just a mistake, they do not indicate a desire to use C++ to compile this code. The modification he wants to perform presents pretty much the same issues in C++ as it does in C; it's merely a coincidence that he's asking about this modification at the same time he decided to change languages. If I'm right, and he is looking for a solution that can be compiled by a conforming C compiler, why is this NOT the right place for him to ask such questions? It's not clear why he decided to switch from C++ to C, but you're surely not hostile to the idea that he might have had a good reason for doing so, are you?
[toc] | [prev] | [next] | [standalone]
| From | Seebs <usenet-nospam@seebs.net> |
|---|---|
| Date | 2011-12-30 00:03 +0000 |
| Message-ID | <slrnjfpvts.vvb.usenet-nospam@guild.seebs.net> |
| In reply to | #15217 |
On 2011-12-29, James Kuyper <jameskuyper@verizon.net> wrote: > The modification he wants to perform presents pretty much the same > issues in C++ as it does in C; it's merely a coincidence that he's > asking about this modification at the same time he decided to change > languages. But it's also a coincidence that it offers the same issues in both languages; there are lots of changes you might make which wouldn't. And that's the thing; a lot of the posters here wouldn't know whether the issues would be the same in C++ or not, and can't test the code as is on a C compiler... > If I'm right, and he is looking for a solution that can be compiled by a > conforming C compiler, why is this NOT the right place for him to ask > such questions? Oh, that might be. But... If he's offering something that cannot possibly ever have even been waved in the direction of a C compiler, the first interpretation that leaps to mind is not "I am later going to have rewritten large hunks of this into C, at which point I want to know how I'd do this." Basically... If the question is about the code as is, it's going to get just as good answers, or better, in a C++ forum. If it's about a hypothetical translation of the code to C, it seems premature. Anything that is using references strikes me as pretty likely to be changed significantly by a conversion to C. -s -- Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! I am not speaking for my employer, although they do rent some of my opinions.
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2011-12-29 21:30 -0500 |
| Message-ID | <jdj7nm$afu$1@dont-email.me> |
| In reply to | #15222 |
On 12/29/2011 07:03 PM, Seebs wrote:
> On 2011-12-29, James Kuyper <jameskuyper@verizon.net> wrote:
>> The modification he wants to perform presents pretty much the same
>> issues in C++ as it does in C; it's merely a coincidence that he's
>> asking about this modification at the same time he decided to change
>> languages.
>
> But it's also a coincidence that it offers the same issues in both languages;
> there are lots of changes you might make which wouldn't.
>
> And that's the thing; a lot of the posters here wouldn't know whether the
> issues would be the same in C++ or not, and can't test the code as is on a
> C compiler...
>
>> If I'm right, and he is looking for a solution that can be compiled by a
>> conforming C compiler, why is this NOT the right place for him to ask
>> such questions?
>
> Oh, that might be. But...
>
> If he's offering something that cannot possibly ever have even been waved in
> the direction of a C compiler, the first interpretation that leaps to mind
> is not "I am later going to have rewritten large hunks of this into C, at
> which point I want to know how I'd do this."
>
> Basically... If the question is about the code as is, it's going to get just
> as good answers, or better, in a C++ forum. If it's about a hypothetical
> translation of the code to C, it seems premature. Anything that is using
> references strikes me as pretty likely to be changed significantly by a
> conversion to C.
Not really - if I were handling it, the first step of the conversion
would be to convert the references to pointers, with corresponding
syntax changes in several locations. My second step would have been to
notice that there was no good reason to use pointers; but under the
circumstances, it seems unlikely that the OP would have noticed that
issue. The only other change that seems required is to replace
cout << "hi" << endl;
with
printf("hi\n");
Were there any other changes needed?
--
James Kuyper
[toc] | [prev] | [next] | [standalone]
| From | Tim Rentsch <txr@alumni.caltech.edu> |
|---|---|
| Date | 2012-01-25 17:47 -0800 |
| Message-ID | <kfn4nvj44l0.fsf@x-alumni2.alumni.caltech.edu> |
| In reply to | #15204 |
Seebs <usenet-nospam@seebs.net> writes: > On 2011-12-29, someone <newsboost@gmail.com> wrote: >>> You are looking fro comp.lang.c++. > >> No I'm not. > > I'm curious as to why you say this. Your code is obviously C++. Nothing > similar to it has ever been part of C. > > Granted that a similar question could apply to C, the mere fact that you're > using references means that the rules for what you're doing are certainly > going to be different. > > So the question is: Why *aren't* you looking for a C++ group? Do you think > that they would be unable to answer your question? If so, why? Just a question here. Did you look at all at the problem he was having and try to decide if it was C related or C++ related? I agree that the code is clearly C++ code; but did you do any looking past that initial impression? I'm just curious.
[toc] | [prev] | [next] | [standalone]
| From | Tim Rentsch <txr@alumni.caltech.edu> |
|---|---|
| Date | 2012-01-25 17:39 -0800 |
| Message-ID | <kfnaa5b44zm.fsf@x-alumni2.alumni.caltech.edu> |
| In reply to | #15186 |
someone <newsboost@gmail.com> writes:
> Hi all
>
> Noob question:
>
> -----------------------------------------------------------------------------
> typedef float GLfloat; // float = GLfloat
>
> void setBezierPoint(const double &x, const double &y, const double &z,
> const int &P, GLfloat bezierCTRpts[][3])
> {
> bezierCTRpts[P][0] = (GLfloat)x;
> bezierCTRpts[P][1] = (GLfloat)y;
> bezierCTRpts[P][2] = (GLfloat)z;
> }
>
>
> void FindBezierControlPointsND(const int *N_kontur,
> const double *cpp_X, const double *cpp_Y, GLfloat bezierData[]
> [3])
> {
> // calculations...
> // set xyz for point P=0 using 4th input parameter:
> setBezierPoint(cpp_X[0], cpp_Y[0], 0.0, 0, bezierData);
>
> // set xyz for point P=3 using 4th input parameter:
> setBezierPoint(cpp_X[0], cpp_Y[0], 0.0, 3, bezierData);
> }
>
>
> int main(int argc, char** argv)
> {
> cout << "hi" << endl;
> GLfloat bezierData[4][3] = {0};
>
> // something
> FindBezierControlPointsND( &N_kontur, Xval, Yval, bezierData);
> }
> -----------------------------------------------------------------------------
>
> Explanation:
>
> I have a static 2D array: bezierData[4][3], 4 points * xyz-coordinates
> and I pass it to FindBezierControlPointsND with this call:
>
> FindBezierControlPointsND( &N_kontur, Xval, Yval, bezierData);
>
> and the function takes: GLfloat bezierData[][3] as input.
> All is ok - the code works, however what I really wanted was to omit
> the 4th input parameter (const int &P) so it looks like:
>
> void setBezierPoint(const double &x, const double &y, const double &z,
> GLfloat bezierCTRpts[][3]) // 4th input is GONE !
> {
> bezierCTRpts[0][0] = (GLfloat)x;
> bezierCTRpts[0][1] = (GLfloat)y;
> bezierCTRpts[0][2] = (GLfloat)z;
> }
>
> Then I wanted to set the xyz-values by a function call like:
>
> - for P=0:
> setBezierPoint(cpp_X[0], cpp_Y[0], 0.0, bezierData[0][0]);
>
> - for P=3:
> setBezierPoint(cpp_X[0], cpp_Y[0], 0.0, bezierData[3][0]);
>
>
> This however doesn't work! I also tried to add "&" in front of
> bezierData[3][0] etc... Error message is something like:
>
> error: cannot convert 'GLfloat* {aka float*}' to 'GLfloat* (*)[3] {aka
> float* (*)[3]}' for argument '4' to 'void setBezierPoint(const
> double&, const double&, const double&, GLfloat* (*)[3])'
Can you answer these questions:
1. What is the type of the expression bezierData[0][0]?
2. What is the type of the expression &bezierData[0][0]?
3. What is the type of the expression bezierData[0]?
4. What is the type of the expression &bezierData[0]?
4. What is the type of the expression bezierData?
5. What is the type of the expression &bezierData?
and finally
6. What is the type of the parameter bezierCTRpts?
If you can answer these questions I believe you will
discover a solution to your problem.
> If you like/ask for it, perhaps I can make a minimal working example.
That's a good idea, not just because it helps people on
the newsgroup, but if you do there is a good chance you'll
discover the answer yourself.
> However, I hope one of you geniuses out there can spot my mistake
> right on :-)
Spotting the mistake is fairly easy. What's harder is
figuring out what makes it unclear to someone asking
the question and how to explain it to them.
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.c
csiph-web