From: John F. F. <joh...@cy...> - 2012-03-16 03:42:16
|
Dee, It is a fallacy of many C manuals that arrays and pointers are the same thing. In many situations they are the same thing, but in function arguments they are not. In a function argument, a pointer is a single variable that points to a block of memory; an array is the actual block of memory itself. So when you pass something into a function as an argument you need to match array to array and pointer to pointer. - John On 3/15/2012 10:26 PM, Diederick C. Niehorster wrote: > I have now updated the Tetrahedon, Cube and SierpinskiSponge code. Its > committed, see revision 1146. > > I have a bit of a C question. > I know have the functions fghCubeGenerate and fghTetrahedonGenerate. > They contents are almost identical, just the sizes of the 2D arrays > are different, and these sizes are known by the values of macros. So I > thought I could write a general function to replace these two, but > that turns out to be difficult. > Something with a signature like > static void fghGenerateGeometry(int numFaces, int numVertPerFace, > GLdouble **vertices, GLubyte** vertIndices, GLdouble **normals, > GLdouble *vertOut, GLdouble *normOut) > compiles (with warnings) but doesn't work. I can't figure pointer and > array types don't mix well. > example warning: > 'GLdouble **' differs in levels of indirection from 'GLdouble [8][3]' > > I don't know pointers and the like well enough to get around this, and > haven't been able to google the answer. Is this possible, and if so, > how? > > Thanks! > Dee > > ------------------------------------------------------------------------------ > This SF email is sponsosred by: > Try Windows Azure free for 90 days Click Here > http://p.sf.net/sfu/sfd2d-msazure > _______________________________________________ > Freeglut-developer mailing list > Fre...@li... > https://lists.sourceforge.net/lists/listinfo/freeglut-developer > > |